Guest User

Untitled

a guest
Feb 7th, 2012
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 20.82 KB | None | 0 0
  1. /** \file copyEngine.cpp
  2. \brief Define the copy engine
  3. \author alpha_one_x86
  4. \version 0.3
  5. \date 2010 */
  6.  
  7. #include <QtCore>
  8. #include <QFileDialog>
  9. #include <QMessageBox>
  10.  
  11. #include "copyEngine.h"
  12. #include "folderExistsDialog.h"
  13.  
  14. /** \note into all the class copyEngine(), dialog.exec() do bug if external close is do */
  15.  
  16. /// \note Can be call without queue because all call will be serialized
  17. void copyEngine::fileAlreadyExists(QFileInfo source,QFileInfo destination,bool isSame,TransferThread * thread,bool isCalledByShowOneNewDialog)
  18. {
  19.     if(stopIt)
  20.         return;
  21.     if(thread==NULL)
  22.     {
  23.         ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Critical,"unable to locate the thread");
  24.         return;
  25.     }
  26.     //load the action
  27.     if(isSame)
  28.     {
  29.         ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"file is same: "+source.absoluteFilePath());
  30.         tempFileExistsAction=alwaysDoThisActionForFileExists;
  31.         if(tempFileExistsAction==FileExists_Overwrite || tempFileExistsAction==FileExists_OverwriteIfNewer || tempFileExistsAction==FileExists_OverwriteIfNotSameModificationDate)
  32.             tempFileExistsAction=FileExists_NotSet;
  33.         switch(tempFileExistsAction)
  34.         {
  35.             case FileExists_Skip:
  36.             case FileExists_Rename:
  37.                 thread->setFileExistsAction(tempFileExistsAction);
  38.             break;
  39.             default:
  40.                 if(dialogIsOpen)
  41.                 {
  42.                     alreadyExistsQueueItem newItem;
  43.                     newItem.source=source;
  44.                     newItem.destination=destination;
  45.                     newItem.isSame=isSame;
  46.                     newItem.transfer=thread;
  47.                     newItem.scan=NULL;
  48.                     alreadyExistsQueue << newItem;
  49.                     return;
  50.                 }
  51.                 dialogIsOpen=true;
  52.                 ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"show dialog");
  53.                 this->isCalledByShowOneNewDialog=isCalledByShowOneNewDialog;
  54.                 fileIsSameDialog_thread=thread;
  55.                 fileIsSameDialog_dialog=new fileIsSameDialog(interface,source);
  56.                 fileIsSameDialog_dialog->setModal(true);
  57.                 emit isInPause(true);
  58.                 connect(fileIsSameDialog_dialog,SIGNAL(finished(int)),this,SLOT(returnFromDialogFileIsSame()),Qt::QueuedConnection);
  59.                 fileIsSameDialog_dialog->show();
  60.                 return;
  61.             break;
  62.         }
  63.     }
  64.     else
  65.     {
  66.         ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"file already exists: "+source.absoluteFilePath()+", destination: "+destination.absoluteFilePath());
  67.         tempFileExistsAction=alwaysDoThisActionForFileExists;
  68.         switch(tempFileExistsAction)
  69.         {
  70.             case FileExists_Skip:
  71.             case FileExists_Rename:
  72.             case FileExists_Overwrite:
  73.             case FileExists_OverwriteIfNewer:
  74.             case FileExists_OverwriteIfNotSameModificationDate:
  75.                 ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"always do this action: "+QString::number(tempFileExistsAction));
  76.                 thread->setFileExistsAction(tempFileExistsAction);
  77.             break;
  78.             default:
  79.                 if(dialogIsOpen)
  80.                 {
  81.                     ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,QString("dialog open, put in queue: %1 %2")
  82.                                  .arg(source.absoluteFilePath())
  83.                                  .arg(destination.absoluteFilePath())
  84.                                  );
  85.                     alreadyExistsQueueItem newItem;
  86.                     newItem.source=source;
  87.                     newItem.destination=destination;
  88.                     newItem.isSame=isSame;
  89.                     newItem.transfer=thread;
  90.                     newItem.scan=NULL;
  91.                     alreadyExistsQueue << newItem;
  92.                     return;
  93.                 }
  94.                 dialogIsOpen=true;
  95.                 ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"show dialog");
  96.                 this->isCalledByShowOneNewDialog=isCalledByShowOneNewDialog;
  97.                 fileExistsDialog_thread=thread;
  98.                 fileExistsDialog_dialog=new fileExistsDialog(interface,source,destination);
  99.                 fileExistsDialog_dialog->setModal(true);
  100.                 emit isInPause(true);
  101.                 connect(fileExistsDialog_dialog,SIGNAL(finished(int)),this,SLOT(returnFromDialogFileExists()),Qt::QueuedConnection);
  102.                 fileExistsDialog_dialog->show();
  103.                 return;
  104.             break;
  105.         }
  106.     }
  107.     ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"stop");
  108. }
  109.  
  110. void copyEngine::returnFromDialogFileIsSame()
  111. {
  112.     disconnect(fileIsSameDialog_dialog,SIGNAL(finished(int)),this,SLOT(returnFromDialogFileIsSame()));
  113.     FileExistsAction newAction=fileIsSameDialog_dialog->getAction();
  114.     emit isInPause(false);
  115.     ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"close dialog: "+QString::number(newAction));
  116.     if(newAction==FileExists_Cancel)
  117.     {
  118.         emit cancelAll();
  119.         return;
  120.     }
  121.     if(fileIsSameDialog_dialog->getAlways() && newAction!=alwaysDoThisActionForFileExists)
  122.     {
  123.         alwaysDoThisActionForFileExists=newAction;
  124.         listThread->setAlwaysFileExistsAction(alwaysDoThisActionForFileExists);
  125.         switch(newAction)
  126.         {
  127.             default:
  128.             case FileExists_Skip:
  129.                 emit newCollisionAction("skip");
  130.             break;
  131.             case FileExists_Rename:
  132.                 emit newCollisionAction("rename");
  133.             break;
  134.         }
  135.     }
  136.     if(fileIsSameDialog_dialog->getAlways() || newAction!=FileExists_Rename)
  137.         fileIsSameDialog_thread->setFileExistsAction(newAction);
  138.     else
  139.         fileIsSameDialog_thread->setFileRename(fileIsSameDialog_dialog->getNewName());
  140.     dialogIsOpen=false;
  141.     if(!isCalledByShowOneNewDialog)
  142.         emit queryOneNewDialog();
  143.     delete fileIsSameDialog_dialog;
  144.     fileIsSameDialog_dialog=NULL;
  145. }
  146.  
  147. void copyEngine::returnFromDialogFileExists()
  148. {
  149.     FileExistsAction newAction=fileExistsDialog_dialog->getAction();
  150.     emit isInPause(false);
  151.     ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"close dialog: "+QString::number(newAction));
  152.     if(newAction==FileExists_Cancel)
  153.     {
  154.         emit cancelAll();
  155.         return;
  156.     }
  157.     if(fileExistsDialog_dialog->getAlways() && newAction!=alwaysDoThisActionForFileExists)
  158.     {
  159.         alwaysDoThisActionForFileExists=newAction;
  160.         listThread->setAlwaysFileExistsAction(alwaysDoThisActionForFileExists);
  161.         switch(newAction)
  162.         {
  163.             default:
  164.             case FileExists_Skip:
  165.                 emit newCollisionAction("skip");
  166.             break;
  167.             case FileExists_Rename:
  168.                 emit newCollisionAction("rename");
  169.             break;
  170.             case FileExists_Overwrite:
  171.                 emit newCollisionAction("overwrite");
  172.             break;
  173.             case FileExists_OverwriteIfNewer:
  174.                 emit newCollisionAction("overwriteIfNewer");
  175.             break;
  176.             case FileExists_OverwriteIfNotSameModificationDate:
  177.                 emit newCollisionAction("overwriteIfNotSameModificationDate");
  178.             break;
  179.         }
  180.     }
  181.     if(fileExistsDialog_dialog->getAlways() || newAction!=FileExists_Rename)
  182.         fileExistsDialog_thread->setFileExistsAction(newAction);
  183.     else
  184.         fileExistsDialog_thread->setFileRename(fileExistsDialog_dialog->getNewName());
  185.     dialogIsOpen=false;
  186.     if(!isCalledByShowOneNewDialog)
  187.     {
  188.         ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"emit queryOneNewDialog()");
  189.         emit queryOneNewDialog();
  190.     }
  191.     delete fileExistsDialog_dialog;
  192.     fileExistsDialog_dialog=NULL;
  193. }
  194.  
  195. /// \note Can be call without queue because all call will be serialized
  196. void copyEngine::errorOnFile(QFileInfo fileInfo,QString errorString,TransferThread * thread,bool isCalledByShowOneNewDialog)
  197. {
  198.     if(stopIt)
  199.         return;
  200.     ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"file have error: "+fileInfo.absoluteFilePath()+", error: "+errorString);
  201.     if(thread==NULL)
  202.     {
  203.         ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Critical,"unable to locate the thread");
  204.         return;
  205.     }
  206.     //load the action
  207.     tempFileErrorAction=alwaysDoThisActionForFileError;
  208.     switch(tempFileErrorAction)
  209.     {
  210.         case FileError_Skip:
  211.             thread->skip();
  212.         return;
  213.         case FileError_Retry:
  214.             thread->retryAfterError();
  215.         return;
  216.         case FileError_PutToEndOfTheList:
  217.             /// \todo do the read transfer locator and put at the end
  218.             ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"todo list item not found");
  219.         return;
  220.         default:
  221.             if(dialogIsOpen)
  222.             {
  223.                 errorQueueItem newItem;
  224.                 newItem.errorString=errorString;
  225.                 newItem.inode=fileInfo;
  226.                 newItem.mkPath=false;
  227.                 newItem.rmPath=false;
  228.                 newItem.scan=NULL;
  229.                 newItem.transfer=thread;
  230.                 errorQueue << newItem;
  231.                 return;
  232.             }
  233.             dialogIsOpen=true;
  234.             ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"show dialog");
  235.             emit error(fileInfo.absoluteFilePath(),fileInfo.size(),fileInfo.lastModified(),errorString);
  236.             fileErrorDialog_dialog=new fileErrorDialog(interface,fileInfo,errorString);
  237.             emit isInPause(true);
  238.             /*dialog.exec();/// \bug crash when external close
  239.             FileErrorAction newAction=dialog.getAction();
  240.             emit isInPause(false);
  241.             ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"close dialog: "+QString::number(newAction));
  242.             if(newAction==FileError_Cancel)
  243.             {
  244.                 emit cancelAll();
  245.                 return;
  246.             }
  247.             if(dialog.getAlways() && newAction!=alwaysDoThisActionForFileError)
  248.             {
  249.                 alwaysDoThisActionForFileError=newAction;
  250.                 switch(newAction)
  251.                 {
  252.                     default:
  253.                     case FileError_Skip:
  254.                         emit newErrorAction("skip");
  255.                     break;
  256.                     case FileError_PutToEndOfTheList:
  257.                         emit newErrorAction("putToEndOfTheList");
  258.                     break;
  259.                 }
  260.             }
  261.             switch(newAction)
  262.             {
  263.                 case FileError_Skip:
  264.                     thread->skip();
  265.                 break;
  266.                 case FileError_Retry:
  267.                     thread->retryAfterError();
  268.                 break;
  269.                 case FileError_PutToEndOfTheList:
  270.                     thread->putAtBottom();
  271.                     /// \todo do the read transfer locator and put at the end
  272.                                         ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Warning,"todo");
  273.                 break;
  274.                 default:
  275.                     ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Warning,"file error action wrong");
  276.                 break;
  277.             }
  278.             dialogIsOpen=false;
  279.             if(!isCalledByShowOneNewDialog)
  280.                 emit queryOneNewDialog();
  281.             else
  282.                 ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"isCalledByShowOneNewDialog==true then not show other dial");*/
  283.             return;
  284.         break;
  285.     }
  286.     ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"stop");
  287. }
  288.  
  289. /// \note Can be call without queue because all call will be serialized
  290. void copyEngine::folderAlreadyExists(QFileInfo source,QFileInfo destination,bool isSame,scanFileOrFolder * thread,bool isCalledByShowOneNewDialog)
  291. {
  292.     if(stopIt)
  293.         return;
  294.     ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"folder already exists: "+source.absoluteFilePath()+", destination: "+destination.absoluteFilePath());
  295.     if(thread==NULL)
  296.     {
  297.         ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Critical,"unable to locate the thread");
  298.         return;
  299.     }
  300.     //load the always action
  301.     tempFolderExistsAction=alwaysDoThisActionForFolderExists;
  302.     switch(tempFolderExistsAction)
  303.     {
  304.         case FolderExists_Skip:
  305.         case FolderExists_Rename:
  306.         case FolderExists_Merge:
  307.             thread->setFolderExistsAction(tempFolderExistsAction);
  308.         break;
  309.         default:
  310.             if(dialogIsOpen)
  311.             {
  312.                 alreadyExistsQueueItem newItem;
  313.                 newItem.source=source;
  314.                 newItem.destination=destination;
  315.                 newItem.isSame=isSame;
  316.                 newItem.transfer=NULL;
  317.                 newItem.scan=thread;
  318.                 alreadyExistsQueue << newItem;
  319.                 return;
  320.             }
  321.             dialogIsOpen=true;
  322.             ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"show dialog");
  323.             folderExistsDialog_dialog=new folderExistsDialog(interface,source,isSame,destination);
  324.             /*dialog.exec();/// \bug crash when external close
  325.             FolderExistsAction newAction=dialog.getAction();
  326.             ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"close dialog: "+QString::number(newAction));
  327.             if(newAction==FolderExists_Cancel)
  328.             {
  329.                 emit cancelAll();
  330.                 return;
  331.             }
  332.             if(dialog.getAlways() && newAction!=alwaysDoThisActionForFolderExists)
  333.             {
  334.                 setComboBoxFolderColision(newAction);
  335.             }
  336.             thread->setFolderExistsAction(newAction);
  337.             dialogIsOpen=false;
  338.             if(!isCalledByShowOneNewDialog)
  339.                 emit queryOneNewDialog();*/
  340.             return;
  341.         break;
  342.     }
  343. }
  344.  
  345. /// \note Can be call without queue because all call will be serialized
  346. /// \todo all this part
  347. void copyEngine::errorOnFolder(QFileInfo fileInfo,QString errorString,scanFileOrFolder * thread,bool isCalledByShowOneNewDialog)
  348. {
  349.     if(stopIt)
  350.         return;
  351.     ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"file have error: "+fileInfo.absoluteFilePath()+", error: "+errorString);
  352.     if(thread==NULL)
  353.     {
  354.         ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Critical,"unable to locate the thread");
  355.         return;
  356.     }
  357.     //load the always action
  358.     tempFileErrorAction=alwaysDoThisActionForFolderError;
  359.     switch(tempFileErrorAction)
  360.     {
  361.         case FileError_Skip:
  362.         case FileError_Retry:
  363.         case FileError_PutToEndOfTheList:
  364.             thread->setFolderErrorAction(tempFileErrorAction);
  365.         break;
  366.         default:
  367.             if(dialogIsOpen)
  368.             {
  369.                 errorQueueItem newItem;
  370.                 newItem.errorString=errorString;
  371.                 newItem.inode=fileInfo;
  372.                 newItem.mkPath=false;
  373.                 newItem.rmPath=false;
  374.                 newItem.scan=thread;
  375.                 newItem.transfer=NULL;
  376.                 errorQueue << newItem;
  377.                 return;
  378.             }
  379.             dialogIsOpen=true;
  380.             ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"show dialog");
  381.             emit error(fileInfo.absoluteFilePath(),fileInfo.size(),fileInfo.lastModified(),errorString);
  382.             fileErrorDialog_dialog=new fileErrorDialog(interface,fileInfo,errorString);
  383.             /*dialog.exec();/// \bug crash when external close
  384.             FileErrorAction newAction=dialog.getAction();
  385.             ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"close dialog: "+QString::number(newAction));
  386.             if(newAction==FileError_Cancel)
  387.             {
  388.                 emit cancelAll();
  389.                 return;
  390.             }
  391.             if(dialog.getAlways() && newAction!=alwaysDoThisActionForFileError)
  392.                 setComboBoxFolderError(newAction);
  393.             dialogIsOpen=false;
  394.             thread->setFolderErrorAction(newAction);
  395.             if(!isCalledByShowOneNewDialog)
  396.                 emit queryOneNewDialog();*/
  397.             return;
  398.         break;
  399.     }
  400.     ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"stop");
  401. }
  402.  
  403. // -----------------------------------------------------
  404.  
  405. //mkpath event
  406. void copyEngine::mkPathErrorOnFolder(QFileInfo folder,QString errorString,bool isCalledByShowOneNewDialog)
  407. {
  408.     if(stopIt)
  409.         return;
  410.     ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"file have error: "+folder.absoluteFilePath()+", error: "+errorString);
  411.     //load the always action
  412.     tempFileErrorAction=alwaysDoThisActionForFolderError;
  413.     error_index=0;
  414.     switch(tempFileErrorAction)
  415.     {
  416.         case FileError_Skip:
  417.             listThread->mkPathQueue.skip();
  418.         return;
  419.         case FileError_Retry:
  420.             listThread->mkPathQueue.retry();
  421.         return;
  422.         case FileError_PutToEndOfTheList:
  423.             while(error_index<listThread->actionToDoList.size())
  424.             {
  425.                 if(listThread->actionToDoList.at(error_index).type==ListThread::ActionType_MkPath)
  426.                 {
  427.                     listThread->mkPathQueue.skip();
  428.                     listThread->actionToDoList.move(error_index,listThread->actionToDoList.size()-1);
  429.                     listThread->actionToDoList[error_index].isRunning=false;
  430.                     listThread->numberOfInodeOperation--;
  431.                     listThread->doNewActions_inode_manipulation();
  432.                     return;
  433.                 }
  434.                 error_index++;
  435.             }
  436.             ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"todo list item not found");
  437.         break;
  438.         default:
  439.             if(dialogIsOpen)
  440.             {
  441.                 errorQueueItem newItem;
  442.                 newItem.errorString=errorString;
  443.                 newItem.inode=folder;
  444.                 newItem.mkPath=true;
  445.                 newItem.rmPath=false;
  446.                 newItem.scan=NULL;
  447.                 newItem.transfer=NULL;
  448.                 errorQueue << newItem;
  449.                 return;
  450.             }
  451.             dialogIsOpen=true;
  452.             ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"show dialog");
  453.             emit error(folder.absoluteFilePath(),folder.size(),folder.lastModified(),errorString);
  454.             fileErrorDialog_dialog=new fileErrorDialog(interface,folder,errorString);
  455.             /*dialog.exec();/// \bug crash when external close
  456.             FileErrorAction newAction=dialog.getAction();
  457.             ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"close dialog: "+QString::number(newAction));
  458.             if(newAction==FileError_Cancel)
  459.             {
  460.                 emit cancelAll();
  461.                 return;
  462.             }
  463.             if(dialog.getAlways() && newAction!=alwaysDoThisActionForFileError)
  464.                 setComboBoxFolderError(newAction);
  465.             dialogIsOpen=false;
  466.             switch(tempFileErrorAction)
  467.             {
  468.                 case FileError_Skip:
  469.                     listThread->mkPathQueue.skip();
  470.                 break;
  471.                 case FileError_Retry:
  472.                     listThread->mkPathQueue.retry();
  473.                 break;
  474.                 case FileError_PutToEndOfTheList:
  475.                     while(error_index<listThread->actionToDoList.size())
  476.                     {
  477.                         if(listThread->actionToDoList.at(error_index).type==ListThread::ActionType_MkPath)
  478.                         {
  479.                             listThread->mkPathQueue.skip();
  480.                             listThread->actionToDoList.move(error_index,listThread->actionToDoList.size()-1);
  481.                             listThread->actionToDoList[error_index].isRunning=false;
  482.                             listThread->numberOfInodeOperation--;
  483.                             listThread->doNewActions_inode_manipulation();
  484.                             break;
  485.                         }
  486.                         error_index++;
  487.                     }
  488.                     ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"todo list item not found");
  489.                 break;
  490.                 default:
  491.                 break;
  492.             }
  493.             if(!isCalledByShowOneNewDialog)
  494.                 emit queryOneNewDialog();*/
  495.             return;
  496.         break;
  497.     }
  498.     ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"stop");
  499. }
  500.  
  501. //rmpath event
  502. void copyEngine::rmPathErrorOnFolder(QFileInfo folder,QString errorString,bool isCalledByShowOneNewDialog)
  503. {
  504.     if(stopIt)
  505.         return;
  506.     ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"file have error: "+folder.absoluteFilePath()+", error: "+errorString);
  507.     //load the always action
  508.     tempFileErrorAction=alwaysDoThisActionForFolderError;
  509.     error_index=0;
  510.     switch(tempFileErrorAction)
  511.     {
  512.         case FileError_Skip:
  513.             listThread->rmPathQueue.skip();
  514.         return;
  515.         case FileError_Retry:
  516.             listThread->rmPathQueue.retry();
  517.         return;
  518.         case FileError_PutToEndOfTheList:
  519.             while(error_index<listThread->actionToDoList.size())
  520.             {
  521.                 if(listThread->actionToDoList.at(error_index).type==ListThread::ActionType_MkPath)
  522.                 {
  523.                     listThread->rmPathQueue.skip();
  524.                     listThread->actionToDoList.move(error_index,listThread->actionToDoList.size()-1);
  525.                     listThread->actionToDoList[error_index].isRunning=false;
  526.                     listThread->numberOfInodeOperation--;
  527.                     listThread->doNewActions_inode_manipulation();
  528.                     return;
  529.                 }
  530.                 error_index++;
  531.             }
  532.             ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"todo list item not found");
  533.         break;
  534.         default:
  535.             if(dialogIsOpen)
  536.             {
  537.                 errorQueueItem newItem;
  538.                 newItem.errorString=errorString;
  539.                 newItem.inode=folder;
  540.                 newItem.mkPath=false;
  541.                 newItem.rmPath=true;
  542.                 newItem.scan=NULL;
  543.                 newItem.transfer=NULL;
  544.                 errorQueue << newItem;
  545.                 return;
  546.             }
  547.             dialogIsOpen=true;
  548.             ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"show dialog");
  549.             emit error(folder.absoluteFilePath(),folder.size(),folder.lastModified(),errorString);
  550.             fileErrorDialog_dialog=new fileErrorDialog(interface,folder,errorString);
  551.             /*dialog.exec();/// \bug crash when external close
  552.             FileErrorAction newAction=dialog.getAction();
  553.             ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"close dialog: "+QString::number(newAction));
  554.             if(newAction==FileError_Cancel)
  555.             {
  556.                 emit cancelAll();
  557.                 return;
  558.             }
  559.             if(dialog.getAlways() && newAction!=alwaysDoThisActionForFileError)
  560.                 setComboBoxFolderError(newAction);
  561.             dialogIsOpen=false;
  562.             switch(tempFileErrorAction)
  563.             {
  564.                 case FileError_Skip:
  565.                     listThread->rmPathQueue.skip();
  566.                 break;
  567.                 case FileError_Retry:
  568.                     listThread->rmPathQueue.retry();
  569.                 break;
  570.                 case FileError_PutToEndOfTheList:
  571.                     while(error_index<listThread->actionToDoList.size())
  572.                     {
  573.                         if(listThread->actionToDoList.at(error_index).type==ListThread::ActionType_MkPath)
  574.                         {
  575.                             listThread->rmPathQueue.skip();
  576.                             listThread->actionToDoList.move(error_index,listThread->actionToDoList.size()-1);
  577.                             listThread->actionToDoList[error_index].isRunning=false;
  578.                             listThread->numberOfInodeOperation--;
  579.                             listThread->doNewActions_inode_manipulation();
  580.                             break;
  581.                         }
  582.                         error_index++;
  583.                     }
  584.                     ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"todo list item not found");
  585.                 break;
  586.                 default:
  587.                 break;
  588.             }
  589.             if(!isCalledByShowOneNewDialog)
  590.                 emit queryOneNewDialog();*/
  591.             return;
  592.         break;
  593.     }
  594.     ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"stop");
  595. }
  596.  
  597. //show one new dialog if needed
  598. void copyEngine::showOneNewDialog()
  599. {
  600.     if(stopIt)
  601.         return;
  602.     ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"alreadyExistsQueue.size(): "+QString::number(alreadyExistsQueue.size()));
  603.     ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Notice,"errorQueue.size(): "+QString::number(errorQueue.size()));
  604.     loop_size=alreadyExistsQueue.size();
  605.     while(loop_size>0)
  606.     {
  607.         if(alreadyExistsQueue.first().transfer!=NULL)
  608.         {
  609.             fileAlreadyExists(alreadyExistsQueue.first().source,
  610.                       alreadyExistsQueue.first().destination,
  611.                       alreadyExistsQueue.first().isSame,
  612.                       alreadyExistsQueue.first().transfer,
  613.                       true);
  614.         }
  615.         else if(alreadyExistsQueue.first().scan!=NULL)
  616.             folderAlreadyExists(alreadyExistsQueue.first().source,
  617.                         alreadyExistsQueue.first().destination,
  618.                         alreadyExistsQueue.first().isSame,
  619.                         alreadyExistsQueue.first().scan,
  620.                         true);
  621.         else
  622.             ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Critical,"bug, no thread actived");
  623.         alreadyExistsQueue.removeFirst();
  624.         loop_size--;
  625.     }
  626.     loop_size=errorQueue.size();
  627.     while(errorQueue.size()>0)
  628.     {
  629.         if(errorQueue.first().transfer!=NULL)
  630.             errorOnFile(errorQueue.first().inode,errorQueue.first().errorString,errorQueue.first().transfer,true);
  631.         else if(errorQueue.first().scan!=NULL)
  632.             errorOnFolder(errorQueue.first().inode,errorQueue.first().errorString,errorQueue.first().scan,true);
  633.         else if(errorQueue.first().mkPath)
  634.             mkPathErrorOnFolder(errorQueue.first().inode,errorQueue.first().errorString,true);
  635.         else if(errorQueue.first().rmPath)
  636.             rmPathErrorOnFolder(errorQueue.first().inode,errorQueue.first().errorString,true);
  637.         else
  638.             ULTRACOPIER_DEBUGCONSOLE(DebugLevel_Critical,"bug, no thread actived");
  639.         errorQueue.removeFirst();
  640.         loop_size--;
  641.     }
  642. }
Advertisement
Add Comment
Please, Sign In to add comment