filemanager/src/filemanager/src/operationservice/fmoperationresultprocesser.cpp
changeset 46 d58987eac7e8
parent 37 15bc28c9dd51
equal deleted inserted replaced
37:15bc28c9dd51 46:d58987eac7e8
    70         QString newTargetPath = FmUtils::fillPathWithSplash(
    70         QString newTargetPath = FmUtils::fillPathWithSplash(
    71                                 srcFileInfo.absolutePath() ) + value;
    71                                 srcFileInfo.absolutePath() ) + value;
    72         QString errString;
    72         QString errString;
    73         // check if name/path is available for use.
    73         // check if name/path is available for use.
    74         if( !FmUtils::checkNewFolderOrFile( value, newTargetPath, errString ) ) {
    74         if( !FmUtils::checkNewFolderOrFile( value, newTargetPath, errString ) ) {
    75             FmDlgUtils::information( errString );
    75             FmDlgUtils::warning( errString, HbMessageBox::Ok, true );
    76             ret = FmDlgUtils::showTextQuery( questionText, value, regExpList, maxFileNameLength, QString(), false );
    76             ret = FmDlgUtils::showTextQuery( questionText, value, regExpList, maxFileNameLength, QString(), false );
    77             continue;
    77             continue;
    78         } else {
    78         } else {
    79             break;
    79             break;
    80         }
    80         }
    84 		*destFile = value;
    84 		*destFile = value;
    85         QFileInfo destFileInfo( *destFile );
    85         QFileInfo destFileInfo( *destFile );
    86         if ( ( srcFileInfo.suffix().compare( destFileInfo.suffix(), Qt::CaseInsensitive ) != 0 )
    86         if ( ( srcFileInfo.suffix().compare( destFileInfo.suffix(), Qt::CaseInsensitive ) != 0 )
    87             && srcFileInfo.isFile() ) {
    87             && srcFileInfo.isFile() ) {
    88             // popup warning when the suffix of file is changed.
    88             // popup warning when the suffix of file is changed.
    89             FmDlgUtils::information( hbTrId( "File may become unusable when file name extension is changed" ) );        
    89             FmDlgUtils::warning( hbTrId( "File may become unusable when file name extension is changed" ) );        
    90         }   
    90         }   
    91 	}
    91 	}
    92 }
    92 }
    93 
    93 
    94 /*
    94 /*
   115  * \sa FmOperationService::on_operation_showNote
   115  * \sa FmOperationService::on_operation_showNote
   116  */
   116  */
   117 void FmOperationResultProcesser::onShowNote( FmOperationBase* operationBase, const char *noteString )
   117 void FmOperationResultProcesser::onShowNote( FmOperationBase* operationBase, const char *noteString )
   118 {
   118 {
   119     Q_UNUSED( operationBase );
   119     Q_UNUSED( operationBase );
   120     FmDlgUtils::information(hbTrId(noteString));
   120     FmDlgUtils::information(hbTrId(noteString), HbMessageBox::Ok, true );
   121 }
   121 }
   122 
   122 
   123 /*
   123 /*
   124  * Called by operation service on_operation_notifyWaiting
   124  * Called by operation service on_operation_notifyWaiting
   125  * \sa FmOperationService::on_operation_notifyWaiting
   125  * \sa FmOperationService::on_operation_notifyWaiting
   173     case FmOperationService::EOperationTypeRemove:
   173     case FmOperationService::EOperationTypeRemove:
   174         title = hbTrId("delete preparing");
   174         title = hbTrId("delete preparing");
   175         break;
   175         break;
   176     case FmOperationService::EOperationTypeFormat:
   176     case FmOperationService::EOperationTypeFormat:
   177         title = hbTrId("format preparing");
   177         title = hbTrId("format preparing");
       
   178         FmUtils::setSystem( true );
   178         break;
   179         break;
   179     default:
   180     default:
   180         break;
   181         break;
   181     }
   182     }
   182 
   183 
   255 				FmUtils::getDriveLetterFromPath( paramFolderDetails->folderPath() ) );
   256 				FmUtils::getDriveLetterFromPath( paramFolderDetails->folderPath() ) );
   256             break;
   257             break;
   257         }
   258         }
   258     case FmOperationService::EOperationTypeFormat:
   259     case FmOperationService::EOperationTypeFormat:
   259         {
   260         {
   260             FmDlgUtils::information( QString( hbTrId("Format succeed!")) );
   261             FmUtils::setSystem( false );
       
   262             FmDlgUtils::information( QString( hbTrId("Format succeed!")), HbMessageBox::Ok, true );
   261             FmOperationFormat *paramFormat = static_cast<FmOperationFormat*>( operationBase );
   263             FmOperationFormat *paramFormat = static_cast<FmOperationFormat*>( operationBase );
   262             QString title( hbTrId( "Drive name ") );  
   264             QString title( hbTrId( "Drive name ") );  
   263             QString driveName( paramFormat->driverName() );
   265             QString driveName( paramFormat->driverName() );
   264             FmDriverInfo driverInfo = FmUtils::queryDriverInfo( driveName );
   266             FmDriverInfo driverInfo = FmUtils::queryDriverInfo( driveName );
   265             FmDriverInfo::DriveState state = driverInfo.driveState();
   267             FmDriverInfo::DriveState state = driverInfo.driveState();
   278                     if ( err == FmErrNone ) {
   280                     if ( err == FmErrNone ) {
   279                         FmDlgUtils::information( hbTrId( "The name has been changed!" ) );
   281                         FmDlgUtils::information( hbTrId( "The name has been changed!" ) );
   280                         mOperationService->on_operation_driveSpaceChanged();
   282                         mOperationService->on_operation_driveSpaceChanged();
   281                         break;
   283                         break;
   282                     } else if( err == FmErrBadName ) {
   284                     } else if( err == FmErrBadName ) {
   283                         FmDlgUtils::information( hbTrId( "Illegal characters! Use only letters and numbers." ) );
   285                         FmDlgUtils::warning( hbTrId( "Illegal characters! Use only letters and numbers." ), HbMessageBox::Ok, true );
   284                     } else{
   286                     } else{
   285                         FmDlgUtils::information( hbTrId( "Error occurred, operation cancelled!" ) );
   287                         FmDlgUtils::warning( hbTrId( "Error occurred, operation cancelled!" ) );
   286                         break;
   288                         break;
   287                     }                
   289                     }                
   288                 }
   290                 }
   289             }
   291             }
   290             break;
   292             break;
   311  */
   313  */
   312 void FmOperationResultProcesser::onNotifyError( FmOperationBase* operationBase, int error, const QString &errString )
   314 void FmOperationResultProcesser::onNotifyError( FmOperationBase* operationBase, int error, const QString &errString )
   313 {
   315 {
   314     Q_UNUSED( errString );
   316     Q_UNUSED( errString );
   315     failAndCloseProgress();
   317     failAndCloseProgress();
       
   318     if( operationBase->operationType() == FmOperationService::EOperationTypeFormat ) {
       
   319         FmUtils::setSystem( false );
       
   320     }
   316     switch( error )
   321     switch( error )
   317     {
   322     {
   318         case FmErrCancel:
   323         case FmErrCancel:
   319             cancelProgress();
   324             cancelProgress();
   320             // Do not pop up general cancel note as it is not needed( according to TB9.2 ).
   325             // Do not pop up general cancel note as it is not needed( according to TB9.2 ).
   323             // as QEventLoop::exec will cause some problem when used for blocking dialog.
   328             // as QEventLoop::exec will cause some problem when used for blocking dialog.
   324 			// HbDialog has already removed exec function which is implemented with QEventLoop::exec.
   329 			// HbDialog has already removed exec function which is implemented with QEventLoop::exec.
   325 			// If need use QEventLoop::exec to block code execute sequence, It should be invoked in a Qt::QueuedConnection slot.
   330 			// If need use QEventLoop::exec to block code execute sequence, It should be invoked in a Qt::QueuedConnection slot.
   326             return;
   331             return;
   327         case FmErrAlreadyStarted:
   332         case FmErrAlreadyStarted:
   328             FmDlgUtils::information( QString( hbTrId("Operation already started!")) );
   333             FmDlgUtils::warning( QString( hbTrId("Operation already started!")) );
   329             return;
   334             return;
   330         case FmErrLocked:
   335         case FmErrLocked:
   331             {
   336             {
   332                 FmOperationBackup *operationBackup = qobject_cast<FmOperationBackup*>(operationBase);
   337                 FmOperationBackup *operationBackup = qobject_cast<FmOperationBackup*>(operationBase);
   333                 if( operationBackup ) {
   338                 if( operationBackup ) {
   334                     // special error note for backup
   339                     // special error note for backup
   335                     QString targetDrive( operationBackup->targetDrive() );
   340                     QString targetDrive( operationBackup->targetDrive() );
   336                     QString defaultDriveVolume( FmUtils::getDefaultVolumeName( targetDrive ) );
   341                     QString defaultDriveVolume( FmUtils::getDefaultVolumeName( targetDrive ) );
   337                     QString driveString( defaultDriveVolume.isEmpty()? targetDrive:defaultDriveVolume );
   342                     QString driveString( defaultDriveVolume.isEmpty()? targetDrive:defaultDriveVolume );
   338                     FmDlgUtils::information( QString( hbTrId("txt_fmgr_info_backup_locked") ).arg( driveString ) );
   343                     FmDlgUtils::warning( QString( hbTrId("txt_fmgr_info_backup_locked") ).arg( driveString ) );
   339                 } else {
   344                 } else {
   340                     FmDlgUtils::information( QString( hbTrId("Operation failed because drive is locked!")) );
   345                     FmDlgUtils::warning( QString( hbTrId("Operation failed because drive is locked!")) );
   341                 }
   346                 }
   342                 return;
   347                 return;
   343             }
   348             }
   344         case FmErrPathNotFound:
   349         case FmErrPathNotFound:
   345             FmDlgUtils::information( QString( hbTrId("Operation failed because can not find target path or drive is not available!") ) );
   350             FmDlgUtils::warning( QString( hbTrId("Operation failed because can not find target path or drive is not available!") ) );
   346             return;
   351             return;
   347         case FmErrCorrupt:
   352         case FmErrCorrupt:
   348             {
   353             {
   349                 FmOperationBackup *operationBackup = qobject_cast<FmOperationBackup*>(operationBase);
   354                 FmOperationBackup *operationBackup = qobject_cast<FmOperationBackup*>(operationBase);
   350                 if( operationBackup ) {
   355                 if( operationBackup ) {
   351                     // special error note for backup
   356                     // special error note for backup
   352                     QString targetDrive( operationBackup->targetDrive() );
   357                     QString targetDrive( operationBackup->targetDrive() );
   353                     QString defaultDriveVolume( FmUtils::getDefaultVolumeName( targetDrive ) );
   358                     QString defaultDriveVolume( FmUtils::getDefaultVolumeName( targetDrive ) );
   354                     QString driveString( defaultDriveVolume.isEmpty()? targetDrive:defaultDriveVolume );
   359                     QString driveString( defaultDriveVolume.isEmpty()? targetDrive:defaultDriveVolume );
   355                     FmDlgUtils::information( QString( hbTrId("txt_fmgr_info_backup_corrupted") ).arg( driveString ) );
   360                     FmDlgUtils::warning( QString( hbTrId("txt_fmgr_info_backup_corrupted") ).arg( driveString ) );
   356                 } else {
   361                 } else {
   357                     FmDlgUtils::information( QString( hbTrId("Operation failed because target media is corrupted!") ) );
   362                     FmDlgUtils::warning( QString( hbTrId("Operation failed because target media is corrupted!") ) );
   358                 }
   363                 }
   359                 return;
   364                 return;
   360             }
   365             }
   361         case FmErrNotReady: // Caused when MMC & OTG is not inserted when start backup
   366         case FmErrNotReady: // Caused when MMC & OTG is not inserted when start backup
   362             {
   367             {
   364                 if( operationBackup ) {
   369                 if( operationBackup ) {
   365                     // special error note for backup
   370                     // special error note for backup
   366                     QString targetDrive( operationBackup->targetDrive() );
   371                     QString targetDrive( operationBackup->targetDrive() );
   367                     QString defaultDriveVolume( FmUtils::getDefaultVolumeName( targetDrive ) );
   372                     QString defaultDriveVolume( FmUtils::getDefaultVolumeName( targetDrive ) );
   368                     QString driveString( defaultDriveVolume.isEmpty()? targetDrive:defaultDriveVolume );
   373                     QString driveString( defaultDriveVolume.isEmpty()? targetDrive:defaultDriveVolume );
   369                     FmDlgUtils::information( QString( hbTrId("txt_fmgr_info_backup_unavailable") ).arg( driveString ) );
   374                     FmDlgUtils::warning( QString( hbTrId("txt_fmgr_info_backup_unavailable") ).arg( driveString ) );
   370                 } else {
   375                 } else {
   371                     FmDlgUtils::information( QString( hbTrId("Operation failed because device is not ready!") ) );
   376                     FmDlgUtils::warning( QString( hbTrId("Operation failed because device is not ready!") ) );
   372                 }
   377                 }
   373                 return;
   378                 return;
   374             }
   379             }
   375         case FmErrDisMounted: // Caused by eject MMC when preparing backup, will be localized later
   380         case FmErrDisMounted: // Caused by eject MMC when preparing backup, will be localized later
   376             FmDlgUtils::information( QString( hbTrId("Operation failed because backup target drive has been removed!") ) );
   381             FmDlgUtils::warning( QString( hbTrId("Operation failed because backup target drive has been removed!") ) );
   377             return;
   382             return;
   378         case FmErrDiskFull:
   383         case FmErrDiskFull:
   379             FmDlgUtils::information( QString( hbTrId("Not enough space. Operation cancelled!")) );
   384             FmDlgUtils::warning( QString( hbTrId("Not enough space. Operation cancelled!")) );
   380             return;
   385             return;
   381         case FmErrCopyDestToSubFolderInSrc:
   386         case FmErrCopyDestToSubFolderInSrc:
   382             FmDlgUtils::information( QString( hbTrId("Can not copy to sub folder!")) );
   387             FmDlgUtils::warning( QString( hbTrId("Can not copy to sub folder!")) );
   383             return;
   388             return;
   384         case FmErrMoveDestToSubFolderInSrc:
   389         case FmErrMoveDestToSubFolderInSrc:
   385             FmDlgUtils::information( QString( hbTrId("Can not move to sub folder!")) );
   390             FmDlgUtils::warning( QString( hbTrId("Can not move to sub folder!")) );
   386             return;
   391             return;
   387         case FmErrCannotRemove:{
   392         case FmErrCannotRemove:{
   388             if( operationBase->operationType() == FmOperationService::EOperationTypeCopy ) {
   393             if( operationBase->operationType() == FmOperationService::EOperationTypeCopy ) {
   389                 // when copy a file/dir to same name destination, and delete dest fail, this error will occur
   394                 // when copy a file/dir to same name destination, and delete dest fail, this error will occur
   390                 FmDlgUtils::information( QString( hbTrId( "Can not copy because %1 can not be deleted!" ).arg( errString ) ) );
   395                 FmDlgUtils::warning( QString( hbTrId( "Can not copy because %1 can not be deleted!" ).arg( errString ) ) );
   391                 return;
   396                 return;
   392             }
   397             }
   393             else if( operationBase->operationType() == FmOperationService::EOperationTypeMove ) {
   398             else if( operationBase->operationType() == FmOperationService::EOperationTypeMove ) {
   394                 // when move a file/dir to same name destination, and delete dest fail, this error will occur
   399                 // when move a file/dir to same name destination, and delete dest fail, this error will occur
   395                 FmDlgUtils::information( QString( hbTrId( "Can not move because %1 can not be deleted!" ).arg( errString ) ) );
   400                 FmDlgUtils::warning( QString( hbTrId( "Can not move because %1 can not be deleted!" ).arg( errString ) ) );
   396                 return;
   401                 return;
   397             }
   402             }
   398             // when delete file/dir fail, this error will occur
   403             // when delete file/dir fail, this error will occur
   399             FmDlgUtils::information( QString( hbTrId( "Can not delete %1!" ).arg( errString ) ) );
   404             FmDlgUtils::warning( QString( hbTrId( "Can not delete %1!" ).arg( errString ) ) );
   400             return; 
   405             return; 
   401         }      
   406         }      
   402         case FmErrRemoveDefaultFolder:{
   407         case FmErrRemoveDefaultFolder:{
   403             if( operationBase->operationType() == FmOperationService::EOperationTypeMove ) {
   408             if( operationBase->operationType() == FmOperationService::EOperationTypeMove ) {
   404                 // when move a default folder
   409                 // when move a default folder
   405                 FmDlgUtils::information( QString( hbTrId( "Could not move because the default folder %1 can not be deleted!" ).arg( errString ) ) );
   410                 FmDlgUtils::warning( QString( hbTrId( "Could not move because the default folder %1 can not be deleted!" ).arg( errString ) ) );
   406                 return;
   411                 return;
   407             }
   412             }
   408             else {
   413             else {
   409                // when delete the default folder
   414                // when delete the default folder
   410                FmDlgUtils::information( QString( hbTrId( "Could not remove the default folder %1 " ).arg( errString ) ) );
   415                FmDlgUtils::warning( QString( hbTrId( "Could not remove the default folder %1 " ).arg( errString ) ) );
   411                return;
   416                return;
   412             }
   417             }
   413         }
   418         }
   414     }
   419     }
   415 
   420 
   416     switch( operationBase->operationType() )
   421     switch( operationBase->operationType() )
   417     {
   422     {
   418     case FmOperationService::EOperationTypeFormat:
   423     case FmOperationService::EOperationTypeFormat:
   419         FmDlgUtils::information( QString( hbTrId("Format failed!")) );
   424         FmDlgUtils::warning( QString( hbTrId("Format failed!")) );
   420         break;
   425         break;
   421     default:
   426     default:
   422         FmDlgUtils::information( QString( hbTrId("Operation failed")) );
   427         FmDlgUtils::warning( QString( hbTrId("Operation failed")) );
   423     }
   428     }
   424 
   429 
   425 }
   430 }
   426 
   431 
   427 /*
   432 /*