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