filemanager/src/filemanager/src/operationservice/fmoperationservice.cpp
changeset 37 15bc28c9dd51
parent 16 ada7962b4308
child 46 d58987eac7e8
equal deleted inserted replaced
16:ada7962b4308 37:15bc28c9dd51
    17  */
    17  */
    18 
    18 
    19 #include "fmoperationservice.h"
    19 #include "fmoperationservice.h"
    20 #include "fmoperationthread.h"
    20 #include "fmoperationthread.h"
    21 #include "fmbackupconfigloader.h"
    21 #include "fmbackupconfigloader.h"
    22 #include "fmbackuprestorehandler.h"
       
    23 #include "fmbkupengine.h"
    22 #include "fmbkupengine.h"
       
    23 #include "fmbackupsettings.h"
    24 #include "fmviewdetailsdialog.h"
    24 #include "fmviewdetailsdialog.h"
    25 #include "fmoperationresultprocesser.h"
    25 #include "fmoperationresultprocesser.h"
    26 #include "fmoperationcopy.h"
    26 #include "fmoperationcopyormove.h"
    27 #include "fmoperationmove.h"
       
    28 #include "fmoperationremove.h"
    27 #include "fmoperationremove.h"
    29 #include "fmoperationformat.h"
    28 #include "fmoperationformat.h"
    30 
    29 #include "fmoperationviewdetails.h"
       
    30 #include "fmbackuprestorehandler.h"
    31 #include <hbaction.h>
    31 #include <hbaction.h>
    32 #include <hbmessagebox.h>
    32 
    33 
    33 /* \fn void driveSpaceChanged( FmOperationBase* operationBase )
       
    34  * This signal is emitted when disk size changed.
       
    35  */
       
    36 
       
    37 /* \fn void notifyWaiting( FmOperationBase* operationBase, bool cancelable )
       
    38  * This signal is emitted when the operation emits notifyWaiting.
       
    39  */
       
    40 
       
    41 /* \fn void notifyPreparing( FmOperationBase* operationBase, bool cancelable )
       
    42  * This signal is emitted when the operation emits notifyPreparing.
       
    43  */
       
    44 
       
    45 /* \fn void notifyStart( FmOperationBase* operationBase, bool cancelable, int maxSteps )
       
    46  * This signal is emitted when the operation emits notifyStart.
       
    47  */
       
    48 
       
    49 /* \fn void notifyProgress( FmOperationBase* operationBase, int currentStep )
       
    50  * This signal is emitted when the operation emits notifyProgress.
       
    51  */
       
    52     
       
    53 /* \fn void notifyFinish( FmOperationBase* operationBase )
       
    54  * This signal is emitted when the operation emits notifyFinish.
       
    55  */ 
       
    56     
       
    57 /* \fn void notifyError( FmOperationBase* operationBase, int error, QString errString )
       
    58  * This signal is emitted when the operation emits notifyError.
       
    59  */ 
       
    60  
       
    61 /* \fn void notifyCanceled( FmOperationBase* operationBase )
       
    62  * This signal is emitted when the operation emits notifyCanceled.
       
    63  */ 
       
    64 
       
    65 /*
       
    66  * Constructs one operation Service with \a parent.
       
    67  */
    34 FmOperationService::FmOperationService( QObject *parent ) : QObject( parent ),
    68 FmOperationService::FmOperationService( QObject *parent ) : QObject( parent ),
    35         mCurrentOperation( 0 )
    69         mCurrentOperation( 0 ), mBackupRestoreHandler( 0 )
    36 {
    70 {
    37     mThread = new FmOperationThread( this );
    71     mThread = new FmOperationThread( this );
    38     mThread->setObjectName( "operationThread" );
    72     mThread->setObjectName( "operationThread" );
    39     mBackupRestoreHandler = new FmBackupRestoreHandler( this );
       
    40     mBackupRestoreHandler->setObjectName( "backupRestore" ) ;
       
    41 
       
    42     mOperationResultProcesser = new FmOperationResultProcesser( this );
    73     mOperationResultProcesser = new FmOperationResultProcesser( this );
    43     
    74     
    44     QMetaObject::connectSlotsByName( this );
    75     QMetaObject::connectSlotsByName( this );
    45 }
    76 }
    46 
    77 
       
    78 /*
       
    79  * Destructs the operation service.
       
    80  */
    47 FmOperationService::~FmOperationService()
    81 FmOperationService::~FmOperationService()
    48 {
    82 {
    49     delete mThread;
    83     delete mThread;    
    50     
    84     mThread = 0;
    51     delete mBackupRestoreHandler;
    85     delete mBackupRestoreHandler;
    52     
    86     mBackupRestoreHandler = 0;
    53 }
    87 }
    54 
    88 
       
    89 /*
       
    90  * Returns true if the thread is running, false if not.
       
    91  */
    55 bool FmOperationService::isRunning()
    92 bool FmOperationService::isRunning()
    56 {
    93 {
    57     if( mCurrentOperation ) {
    94     return mThread->isRunning();    
    58         return true;
    95 }
    59     } else {
    96 
    60         return false;
    97 /*
    61     }
    98  * Copies the file or foler \a targetPath asynchronously. 
    62     
    99  */
    63 }
   100 int FmOperationService::asyncCopy( const QStringList &sourceList, const QString &targetPath )
    64 
   101 {    
    65 int FmOperationService::asyncCopy( QStringList sourceList, QString targetPath )
   102     Q_ASSERT( !mCurrentOperation ); 
    66 {
   103     mCurrentOperation  = new FmOperationCopyOrMove( this, FmOperationService::EOperationTypeCopy, sourceList, targetPath );
    67     if ( isRunning() )
   104     connectSignalsAndSlots( mCurrentOperation );
    68         return FmErrAlreadyStarted;
   105     int ret = mThread->prepareOperationAndStart( mCurrentOperation );    
       
   106     if ( ret!= FmErrNone ) {
       
   107         resetOperation();
       
   108         return ret; 
       
   109     }        
       
   110     return FmErrNone;
       
   111 }
       
   112 
       
   113 /*
       
   114  * Moves the file or foler \a sourceList to \a targetPath asynchronously. 
       
   115  */
       
   116 int FmOperationService::asyncMove( const QStringList &sourceList, const QString &targetPath )
       
   117 {
    69     Q_ASSERT( !mCurrentOperation );
   118     Q_ASSERT( !mCurrentOperation );
    70      
   119 
    71     if( sourceList.empty() ) {
   120     mCurrentOperation  = new FmOperationCopyOrMove( this, FmOperationService::EOperationTypeMove, sourceList, targetPath );
    72         return FmErrWrongParam;
   121     connectSignalsAndSlots( mCurrentOperation );
    73     }
   122     int ret = mThread->prepareOperationAndStart( mCurrentOperation );    
    74     mCurrentOperation = new FmOperationCopy( mThread, sourceList, targetPath );
   123     if ( ret!= FmErrNone ) {
    75 
   124         resetOperation();
    76     int ret = mThread->asyncCopy( mCurrentOperation );
   125         return ret; 
    77     if( ret != FmErrNone ) {
   126     }        
    78         resetOperation();
   127     return FmErrNone;
    79     }
   128 }
    80     return ret;
   129 
    81 }
   130 /*
    82 
   131  * Removes the file or dir \a pathList asynchronously. 
    83 int FmOperationService::asyncMove( QStringList sourceList, QString targetPath )
   132  */
    84 {
   133 int FmOperationService::asyncRemove( const QStringList &pathList )
    85     if ( isRunning() )
   134 {
    86         return FmErrAlreadyStarted;
   135     Q_ASSERT( !mCurrentOperation ); 
       
   136 
       
   137     mCurrentOperation = new FmOperationRemove( this, pathList );
       
   138     connectSignalsAndSlots( mCurrentOperation );
       
   139     int ret = mThread->prepareOperationAndStart( mCurrentOperation );    
       
   140     if ( ret!= FmErrNone ) {
       
   141         resetOperation();
       
   142         return ret; 
       
   143     }        
       
   144     return FmErrNone;
       
   145 }
       
   146 
       
   147 /*
       
   148  * Formats the drive \a driverName asynchronously. 
       
   149  */
       
   150 int FmOperationService::asyncFormat( const QString &driverName )
       
   151 {
    87     Q_ASSERT( !mCurrentOperation );
   152     Q_ASSERT( !mCurrentOperation );
    88 
   153 
    89     if( sourceList.empty() ) {
   154     mCurrentOperation = new FmOperationFormat( this, driverName );
    90         return FmErrWrongParam;
   155     connectSignalsAndSlots( mCurrentOperation );
    91     }
   156     int ret = mThread->prepareOperationAndStart( mCurrentOperation );    
    92     mCurrentOperation = new FmOperationMove( mThread, sourceList, targetPath );
   157     if ( ret!= FmErrNone ) {
    93 
   158         resetOperation();
    94     int ret = mThread->asyncMove( mCurrentOperation );
   159         return ret; 
    95     if( ret != FmErrNone ) {
   160     }        
    96         resetOperation();
   161     return FmErrNone;
    97     }
   162 }
    98     return ret;
   163 
    99 }
   164 /*
   100 
   165  * Views drive \a driverName details asynchronously.
   101 int FmOperationService::asyncRemove( QStringList pathList )
   166  */
   102 {
   167 int FmOperationService::asyncViewDriveDetails( const QString &driverName )
   103     if ( isRunning() )
   168 {
   104         return FmErrAlreadyStarted;
       
   105     Q_ASSERT( !mCurrentOperation ); 
       
   106 
       
   107     mCurrentOperation = new FmOperationRemove( mThread, pathList );
       
   108 
       
   109     int ret = mThread->asyncRemove( mCurrentOperation );
       
   110     if( ret != FmErrNone ) {
       
   111         resetOperation();
       
   112     }
       
   113     return ret;
       
   114 }
       
   115 
       
   116 int FmOperationService::asyncFormat( QString driverName )
       
   117 {
       
   118     if ( isRunning() )
       
   119         return FmErrAlreadyStarted;
       
   120     Q_ASSERT( !mCurrentOperation );
   169     Q_ASSERT( !mCurrentOperation );
   121 
   170     
   122     mCurrentOperation = new FmOperationFormat( mThread, driverName );
   171     mCurrentOperation = new FmOperationDriveDetails( this, driverName );
   123 
   172     connectSignalsAndSlots( mCurrentOperation );
   124     int ret = mThread->asyncFormat( mCurrentOperation );
   173     int ret = mThread->prepareOperationAndStart( mCurrentOperation );    
   125     if( ret != FmErrNone ) {
   174     if ( ret!= FmErrNone ) {
   126         resetOperation();
   175         resetOperation();
   127     }
   176         return ret; 
   128     return ret;
   177     }        
   129 }
   178     return FmErrNone;
   130 int FmOperationService::asyncViewDriveDetails( const QString driverName )
   179 }
   131 {
   180 
   132     if ( isRunning() )
   181 /*
   133         return FmErrAlreadyStarted;
   182  * Views folder \a folderPath details asynchronously. 
       
   183  */
       
   184 int FmOperationService::asyncViewFolderDetails( const QString &folderPath )
       
   185 {
   134     Q_ASSERT( !mCurrentOperation );
   186     Q_ASSERT( !mCurrentOperation );
   135 
   187     
   136     mCurrentOperation = new FmOperationDriveDetails( mThread, driverName );
   188     mCurrentOperation = new FmOperationFolderDetails( this, folderPath );
   137 
   189     connectSignalsAndSlots( mCurrentOperation );
   138     int ret = mThread->asyncViewDriveDetails( mCurrentOperation );
   190     int ret = mThread->prepareOperationAndStart( mCurrentOperation );    
   139     if( ret != FmErrNone ) {
   191     if ( ret!= FmErrNone ) {
   140         resetOperation();
   192         resetOperation();
   141     }
   193         return ret; 
   142     return ret;
   194     }        
   143 }
   195     return FmErrNone;
   144 
   196 }
   145 int FmOperationService::asyncViewFolderDetails( const QString folderPath )
   197 
   146 {
   198 /*
   147     if ( isRunning() )
   199  * Backups asynchronously. 
   148         return FmErrAlreadyStarted;
   200  */
   149     Q_ASSERT( !mCurrentOperation );
       
   150 
       
   151     mCurrentOperation = new FmOperationFolderDetails( mThread, folderPath );
       
   152 
       
   153     int ret = mThread->asyncViewFolderDetails( mCurrentOperation );
       
   154     if( ret != FmErrNone ) {
       
   155         resetOperation();
       
   156     }
       
   157     return ret;
       
   158 }
       
   159 
       
   160 int FmOperationService::asyncBackup()
   201 int FmOperationService::asyncBackup()
   161 {   
   202 {   
   162     if ( isRunning() )
   203     if ( isRunning() )
   163         return FmErrAlreadyStarted;
   204         return FmErrAlreadyStarted;
   164     Q_ASSERT( !mCurrentOperation );
   205     Q_ASSERT( !mCurrentOperation );
   165 
   206 
   166     FmOperationBackup *operationBackup = new FmOperationBackup( mBackupRestoreHandler );
   207     // BackupSettingsL will not leave, coding convention will be improvied in another task.
       
   208     QString targetDrive( backupRestoreHandler()->bkupEngine()->BackupSettingsL()->availableTargetDrive() );
       
   209     quint32 content( backupRestoreHandler()->bkupEngine()->BackupSettingsL()->content() );
       
   210     FmOperationBackup *operationBackup = 
       
   211             new FmOperationBackup( backupRestoreHandler(), targetDrive, content );
   167     mCurrentOperation = operationBackup;
   212     mCurrentOperation = operationBackup;
   168     int ret = backupRestoreHandler()->startBackup( operationBackup );
   213     int ret = backupRestoreHandler()->startBackup( operationBackup );
   169     if( ret ){
   214     if( ret ){
   170         return FmErrNone;
   215         return FmErrNone;
   171     } else {
   216     } else {
   172         resetOperation();
   217         resetOperation();
   173         return backupRestoreHandler()->error();
   218         return backupRestoreHandler()->error();
   174     }
   219     }
   175 }
   220 }
   176 
   221 
       
   222 /*
       
   223  * Restores asynchronously. 
       
   224  * \a selection selected restore items
       
   225  */
   177 int FmOperationService::asyncRestore( quint64 selection )
   226 int FmOperationService::asyncRestore( quint64 selection )
   178 {
   227 {
   179     if ( isRunning() )
   228     if ( isRunning() )
   180         return FmErrAlreadyStarted;
   229         return FmErrAlreadyStarted;
   181     Q_ASSERT( !mCurrentOperation );
   230     Q_ASSERT( !mCurrentOperation );
   189         resetOperation();
   238         resetOperation();
   190         return backupRestoreHandler()->error();
   239         return backupRestoreHandler()->error();
   191     }
   240     }
   192 }
   241 }
   193 
   242 
       
   243 /*
       
   244  * Delete backup synchronously. 
       
   245  * \a selection selected backup items
       
   246  */
   194 int FmOperationService::syncDeleteBackup( quint64 selection )
   247 int FmOperationService::syncDeleteBackup( quint64 selection )
   195 {
   248 {
   196     return mBackupRestoreHandler->deleteBackup( selection );
   249     return backupRestoreHandler()->deleteBackup( selection );
   197 }
   250 }
   198 
   251 
       
   252 /*
       
   253  * Cancels current operation.
       
   254  */
   199 void FmOperationService::cancelOperation()
   255 void FmOperationService::cancelOperation()
   200 {
   256 {
   201     switch( mCurrentOperation->operationType() )
   257     switch( mCurrentOperation->operationType() )
   202     {
   258     {
   203     case  EOperationTypeBackup:
   259     case  EOperationTypeBackup:
   224     default:
   280     default:
   225         Q_ASSERT( false );
   281         Q_ASSERT( false );
   226     }    
   282     }    
   227 }
   283 }
   228 
   284 
   229 
   285 /*
       
   286  * Set valume synchronously. not used.
       
   287  */
   230 int FmOperationService::syncSetVolume( const QString &driverName, const QString &volume )
   288 int FmOperationService::syncSetVolume( const QString &driverName, const QString &volume )
   231 {
   289 {
   232     Q_UNUSED( driverName );
   290     Q_UNUSED( driverName );
   233     Q_UNUSED( volume );
   291     Q_UNUSED( volume );
   234     return FmErrNone;
   292     return FmErrNone;
   235 }
   293 }
   236 
   294 
       
   295 /*
       
   296  * Set drive password synchronously. not used.
       
   297  */
   237 int FmOperationService::syncSetdDriverPassword( const QString &driverName,
   298 int FmOperationService::syncSetdDriverPassword( const QString &driverName,
   238                                                const QString &oldPassword, 
   299                                                const QString &oldPassword, 
   239                                                const QString &newPassword )
   300                                                const QString &newPassword )
   240 {
   301 {
   241     Q_UNUSED( driverName );
   302     Q_UNUSED( driverName );
   242     Q_UNUSED( oldPassword );
   303     Q_UNUSED( oldPassword );
   243     Q_UNUSED( newPassword );
   304     Q_UNUSED( newPassword );
   244     return FmErrNone;
   305     return FmErrNone;
   245 }
   306 }
   246 
   307 
       
   308 /*
       
   309  * Rename synchronously. not used.
       
   310  */
   247 int FmOperationService::syncRename( const QString &oldPath, const QString &newName )
   311 int FmOperationService::syncRename( const QString &oldPath, const QString &newName )
   248 {
   312 {
   249     Q_UNUSED( oldPath );
   313     Q_UNUSED( oldPath );
   250     Q_UNUSED( newName );
   314     Q_UNUSED( newName );
   251     return FmErrNone;
   315     return FmErrNone;
   252 }
   316 }
   253 
   317 
       
   318 /*
       
   319  * Launches the file in synchronous way.
       
   320  */
   254 int FmOperationService::syncLaunchFileOpen( const QString &filePath )
   321 int FmOperationService::syncLaunchFileOpen( const QString &filePath )
   255 {
   322 {
   256     return FmUtils::launchFile( filePath );
   323     return FmUtils::launchFile( filePath );
   257 }
   324 }
   258 
   325 
   259 
   326 /*
   260 
   327  * Returns the backup handler.
       
   328  */
   261 FmBackupRestoreHandler *FmOperationService::backupRestoreHandler()
   329 FmBackupRestoreHandler *FmOperationService::backupRestoreHandler()
   262 {
   330 {
   263     if( !mBackupRestoreHandler ) {
   331     if( !mBackupRestoreHandler ) {
   264         mBackupRestoreHandler = new FmBackupRestoreHandler( this );
   332         mBackupRestoreHandler = new FmBackupRestoreHandler( this );        
       
   333         mBackupRestoreHandler->setObjectName( "backupRestore" ) ;
   265         QMetaObject::connectSlotsByName( this );
   334         QMetaObject::connectSlotsByName( this );
   266     }
   335     }
   267     return mBackupRestoreHandler;
   336     return mBackupRestoreHandler;
   268 }
   337 }
   269 
   338 
       
   339 /*
       
   340  * Deletes the operation and set it to be 0.
       
   341  */
   270 void FmOperationService::resetOperation()
   342 void FmOperationService::resetOperation()
   271 {
   343 {
   272    if( mCurrentOperation ) {
   344    if( mCurrentOperation ) {
   273         delete mCurrentOperation;
   345         delete mCurrentOperation;
   274         mCurrentOperation = 0;
   346         mCurrentOperation = 0;
   275     }
   347     }
   276 }
   348 }
   277 
   349 
   278 /////////////////////////////////////////////////////
   350 /*
   279 ///Thread
   351  * Connects \a operation's sinals to slots
   280 void FmOperationService::on_operationThread_askForRename( const QString &srcFile, QString *destFile )
   352  */
       
   353 void FmOperationService::connectSignalsAndSlots( FmOperationBase *operation )
       
   354 {
       
   355     
       
   356     connect( operation, SIGNAL( showNote( QString ) ),
       
   357             this, SLOT( on_operation_showNote( QString )), Qt::BlockingQueuedConnection );
       
   358     connect( operation, SIGNAL( notifyError( int, QString ) ),
       
   359             this, SLOT( on_operation_notifyError( int, QString ) ) );
       
   360     connect( operation, SIGNAL( notifyStart( bool, int ) ),
       
   361             this, SLOT( on_operation_notifyStart( bool, int ) ) );
       
   362     connect( operation, SIGNAL( notifyProgress( int ) ),
       
   363             this, SLOT( on_operation_notifyProgress( int ) ) );
       
   364     connect( operation, SIGNAL( notifyFinish() ),
       
   365             this, SLOT( on_operation_notifyFinish()) );
       
   366     connect( operation, SIGNAL( notifyWaiting( bool ) ),
       
   367             this, SLOT( on_operation_notifyWaiting( bool )) );   
       
   368     
       
   369 }
       
   370 
       
   371 /*
       
   372  * Responds to mCurrentOperation's askForRename signal.
       
   373  * \a srcFile the source file.
       
   374  * \a destFile the new file name.
       
   375  */
       
   376 void FmOperationService::on_operation_askForRename( const QString &srcFile, QString *destFile )
   281 {
   377 {
   282     mOperationResultProcesser->onAskForRename(
   378     mOperationResultProcesser->onAskForRename(
   283         mCurrentOperation, srcFile, destFile );
   379         mCurrentOperation, srcFile, destFile );
   284 }
   380 }
   285 
   381 
   286 void FmOperationService::on_operationThread_askForReplace( const QString &srcFile, const QString &destFile, bool *isAccepted )
   382 /*
       
   383  * Responds to mCurrentOperation's askForReplace signal.
       
   384  * \a srcFile the source file.
       
   385  * \a destFile the target file.
       
   386  * \a isAccepted whether to replace the target file.
       
   387  */
       
   388 void FmOperationService::on_operation_askForReplace( const QString &srcFile, const QString &destFile, bool *isAccepted )
   287 {
   389 {
   288     mOperationResultProcesser->onAskForReplace(
   390     mOperationResultProcesser->onAskForReplace(
   289         mCurrentOperation, srcFile, destFile, isAccepted );
   391         mCurrentOperation, srcFile, destFile, isAccepted );
   290 }
   392 }
   291 
   393 
   292 void FmOperationService::on_operationThread_refreshModel( const QString &path )
   394 /*
   293 {
   395  * Responds to mCurrentOperation's showNote signal.
   294     emit refreshModel( mCurrentOperation, path );
   396  * \a noteString the note content.
   295 }
   397  */
   296 void FmOperationService::on_operationThread_notifyWaiting( bool cancelable )
   398 void FmOperationService::on_operation_showNote( const char *noteString )
       
   399 {
       
   400     mOperationResultProcesser->onShowNote( mCurrentOperation, noteString );
       
   401 }
       
   402 
       
   403 /*
       
   404  * Responds to mCurrentOperation's showNote signal.
       
   405  * \a noteString the note content.
       
   406  */
       
   407 void FmOperationService::on_operation_notifyWaiting( bool cancelable )
   297 {
   408 {
   298     mOperationResultProcesser->onNotifyWaiting(
   409     mOperationResultProcesser->onNotifyWaiting(
   299         mCurrentOperation, cancelable );
   410         mCurrentOperation, cancelable );
   300     emit notifyWaiting( mCurrentOperation, cancelable );
   411     emit notifyWaiting( mCurrentOperation, cancelable );
   301 }
   412 }
   302 void FmOperationService::on_operationThread_notifyPreparing( bool cancelable )
   413 
       
   414 /*
       
   415  * Responds to mCurrentOperation's notifyPreparing signal.
       
   416  * \a cancelable indicates whether the progress bar could be cancelled.
       
   417  */
       
   418 void FmOperationService::on_operation_notifyPreparing( bool cancelable )
   303 {
   419 {
   304     mOperationResultProcesser->onNotifyPreparing(
   420     mOperationResultProcesser->onNotifyPreparing(
   305         mCurrentOperation, cancelable );
   421         mCurrentOperation, cancelable );
   306     emit notifyPreparing( mCurrentOperation, cancelable );
   422     emit notifyPreparing( mCurrentOperation, cancelable );
   307 }
   423 }
   308 void FmOperationService::on_operationThread_notifyStart( bool cancelable, int maxSteps )
   424 
       
   425 /*
       
   426  * Responds to mCurrentOperation's notifyPreparing signal.
       
   427  * \a cancelable indicates whether the progress bar could be cancelled.
       
   428  * \maxSteps the length of progress bar.
       
   429  */
       
   430 void FmOperationService::on_operation_notifyStart( bool cancelable, int maxSteps )
   309 {
   431 {
   310     mOperationResultProcesser->onNotifyStart(
   432     mOperationResultProcesser->onNotifyStart(
   311         mCurrentOperation, cancelable, maxSteps );
   433         mCurrentOperation, cancelable, maxSteps );
   312     emit notifyStart( mCurrentOperation, cancelable, maxSteps );
   434     emit notifyStart( mCurrentOperation, cancelable, maxSteps );
   313 }
   435 }
   314 void FmOperationService::on_operationThread_notifyProgress( int currentStep )
   436 
       
   437 /*
       
   438  * Responds to mCurrentOperation's notifyPreparing signal.
       
   439  * \a currentStep indicates the current length of progress bar.
       
   440  */
       
   441 void FmOperationService::on_operation_notifyProgress( int currentStep )
   315 {
   442 {
   316     mOperationResultProcesser->onNotifyProgress(
   443     mOperationResultProcesser->onNotifyProgress(
   317         mCurrentOperation, currentStep );
   444         mCurrentOperation, currentStep );
   318     emit notifyProgress( mCurrentOperation, currentStep );
   445     emit notifyProgress( mCurrentOperation, currentStep );
   319 }
   446 }
   320 void FmOperationService::on_operationThread_notifyFinish()
   447 
       
   448 /*
       
   449  * Responds to mCurrentOperation's notifyFinish signal, indicate the
       
   450  * progress is over.
       
   451  */
       
   452 void FmOperationService::on_operation_notifyFinish()
   321 {
   453 {
   322     mOperationResultProcesser->onNotifyFinish( mCurrentOperation );
   454     mOperationResultProcesser->onNotifyFinish( mCurrentOperation );
   323     emit notifyFinish( mCurrentOperation );
   455     emit notifyFinish( mCurrentOperation );
   324     resetOperation();
   456     resetOperation();
   325 }
   457 }
   326 void FmOperationService::on_operationThread_notifyError(int error, QString errString )
   458 
       
   459 /*
       
   460  * Responds to mCurrentOperation's notifyError signal.
       
   461  * \a error error id.
       
   462  * \a errString the error string.
       
   463  */
       
   464 void FmOperationService::on_operation_notifyError(int error, QString errString )
   327 {
   465 {
   328     mOperationResultProcesser->onNotifyError(
   466     mOperationResultProcesser->onNotifyError(
   329         mCurrentOperation, error, errString );
   467         mCurrentOperation, error, errString );
   330     emit notifyError( mCurrentOperation, error, errString );
   468     emit notifyError( mCurrentOperation, error, errString );
   331     resetOperation();
   469     resetOperation();
   332 }
   470 }
   333 void FmOperationService::on_operationThread_notifyCanceled()
   471 
   334 {
   472 /*
   335     mOperationResultProcesser->onNotifyCanceled(
   473  * Responds to mCurrentOperation's driveSpaceChanged 
   336         mCurrentOperation );
   474  */
   337     emit notifyCanceled( mCurrentOperation );
   475 void FmOperationService::on_operation_driveSpaceChanged()
   338     resetOperation();
   476 {
   339 }
   477     emit driveSpaceChanged( mCurrentOperation );
   340 ///
   478 }
   341 /////////////////////////////////////////////////////
   479 
   342 
   480 /*
   343 /////////////////////////////////////////////////////
   481  * Responds to mBackupRestoreHandler's notifyPreparing 
   344 ///BackupRestore
   482  * \a cancelable indicates whether it could be cancelled.
       
   483  */
   345 void FmOperationService::on_backupRestore_notifyPreparing( bool cancelable )
   484 void FmOperationService::on_backupRestore_notifyPreparing( bool cancelable )
   346 {
   485 {
   347     mOperationResultProcesser->onNotifyPreparing(
   486     mOperationResultProcesser->onNotifyPreparing(
   348         mCurrentOperation, cancelable );
   487         mCurrentOperation, cancelable );
   349      emit notifyPreparing( mCurrentOperation, cancelable );
   488      emit notifyPreparing( mCurrentOperation, cancelable );
   350 }
   489 }
       
   490 
       
   491 /*
       
   492  * Responds to mBackupRestoreHandler's notifyStart 
       
   493  * \a cancelable indicates whether it could be cancelled.
       
   494  * \a maxSteps the lenth of progress bar.
       
   495  */
   351 void FmOperationService::on_backupRestore_notifyStart( bool cancelable, int maxSteps )
   496 void FmOperationService::on_backupRestore_notifyStart( bool cancelable, int maxSteps )
   352 {
   497 {
   353     mOperationResultProcesser->onNotifyStart(
   498     mOperationResultProcesser->onNotifyStart(
   354         mCurrentOperation, cancelable, maxSteps );
   499         mCurrentOperation, cancelable, maxSteps );
   355     emit notifyStart( mCurrentOperation, cancelable, maxSteps );
   500     emit notifyStart( mCurrentOperation, cancelable, maxSteps );
   356 }
   501 }
       
   502 
       
   503 /*
       
   504  * Responds to mBackupRestoreHandler's notifyProgress 
       
   505  * \a currentStep the current progress bar's step.
       
   506  */
   357 void FmOperationService::on_backupRestore_notifyProgress( int currentStep )
   507 void FmOperationService::on_backupRestore_notifyProgress( int currentStep )
   358 {
   508 {
   359     mOperationResultProcesser->onNotifyProgress(
   509     mOperationResultProcesser->onNotifyProgress(
   360         mCurrentOperation, currentStep );
   510         mCurrentOperation, currentStep );
   361     emit notifyProgress( mCurrentOperation, currentStep );
   511     emit notifyProgress( mCurrentOperation, currentStep );
   362 }
   512 }
       
   513 
       
   514 /*
       
   515  * Responds to mBackupRestoreHandler's notifyFinish 
       
   516  */
   363 void FmOperationService::on_backupRestore_notifyFinish()
   517 void FmOperationService::on_backupRestore_notifyFinish()
   364 {
   518 {
   365     mOperationResultProcesser->onNotifyFinish( mCurrentOperation );
   519     mOperationResultProcesser->onNotifyFinish( mCurrentOperation );
   366     emit notifyFinish( mCurrentOperation );
   520     emit notifyFinish( mCurrentOperation );
   367     resetOperation();
   521     resetOperation();
   368 }
   522 }
   369 void FmOperationService::on_backupRestore_notifyError(int error, QString errString )
   523 
       
   524 /*
       
   525  * Responds to mBackupRestoreHandler's notifyError
       
   526  * \a error the error id.
       
   527  * \a errString the error string.
       
   528  */
       
   529 void FmOperationService::on_backupRestore_notifyError(int error, const QString &errString )
   370 {
   530 {
   371     mOperationResultProcesser->onNotifyError(
   531     mOperationResultProcesser->onNotifyError(
   372         mCurrentOperation, error, errString );
   532         mCurrentOperation, error, errString );
   373     emit notifyError( mCurrentOperation, error, errString );
   533     emit notifyError( mCurrentOperation, error, errString );
   374     resetOperation();
   534     resetOperation();
   375 }
   535 }
       
   536 
       
   537 /*
       
   538  * Responds to mBackupRestoreHandler's notifyCanceled 
       
   539  */
   376 void FmOperationService::on_backupRestore_notifyCanceled()
   540 void FmOperationService::on_backupRestore_notifyCanceled()
   377 {
   541 {
   378     mOperationResultProcesser->onNotifyCanceled(
   542     mOperationResultProcesser->onNotifyError(
   379         mCurrentOperation );
   543         mCurrentOperation, FmErrCancel, QString() );
   380     emit notifyCanceled( mCurrentOperation );
   544     emit notifyError( mCurrentOperation, FmErrCancel, QString() );
   381     resetOperation();
   545     resetOperation();
   382 }
   546 }
   383 
   547 
   384 ///
   548 ///
   385 /////////////////////////////////////////////////////
   549 /////////////////////////////////////////////////////