Logo Search packages:      
Sourcecode: ultracopier version File versions  Download package

void UIcon::dispatchParam ( QStringList  argumentsUltracopier,
QLocalSocket *  client = NULL,
quint32  copyId = 0,
quint32  protocolVersionOfThisQuery = 0 
)

For give to UIcon the application arguments.

Should be create a copy or moving threads The argument should be for copy: cp file.txt file2.txt cp folder/ dest/ cp folder1/ folder2/ dest/ cp file1.txt file2.txt dest/ Same with mv for move

Note:
cp = direct file name, Copy = File list
Parameters:
argumentsUltracopierList of arguments give to the application
clientthe client
copyIdThe copy id
protocolVersionOfThisQueryThe version protocol

Definition at line 282 of file UIcon.cpp.

References CopyAction(), MoveAction(), showDelayedPopup(), theMainWindowCopyMove, UIconIsListen, and windowIsPreloaded.

Referenced by parseTheCleanedTrame().

{
      if(argumentsUltracopier.size()<=0)
      {
            DEBUGCONSOLE(10,"UIcon::dispatchParam","argumentsUltracopier.size() is <=0, it's not normal!");
            return;
      }
      else
      {
            //If not in listen mode is useless to continu
            if(UIconIsListen)
            {
                  bool isOk=true;
                  if(argumentsUltracopier.size()<3)
                        isOk=false;
                  else
                  {
                        DEBUGCONSOLE(30,"UIcon::dispatchParam","argumentsUltracopier.last(): "+argumentsUltracopier.last());
                        QFileInfo theDest(argumentsUltracopier.last());
                        if(theDest.isFile() && argumentsUltracopier.size()>3)
                              isOk=false;
                  }
                  if(!isOk)
                  {
                        #if (DEBUG_ULTRACOPIER>0)
                              DEBUGCONSOLE(30,"UIcon::dispatchParam","number of argument: "+QString::number(argumentsUltracopier.size()));
                              for (int i = 0; i < argumentsUltracopier.size(); ++i) {
                                    DEBUGCONSOLE(30,"UIcon::dispatchParam","argument["+QString::number(i)+"]: "+argumentsUltracopier.at(i));
                              }
                        #endif
                        if(argumentsUltracopier.at(0)=="AddEmpty")
                        {
                              DEBUGCONSOLE(30,"UIcon::dispatchParam","Open new copy windows, and first param: AddEmpty");
                              Main_window *main=NULL;
                              main = CopyAction();
                        }
                        else if(argumentsUltracopier.at(0)=="Running")
                        {
                              DEBUGCONSOLE(30,"UIcon::dispatchParam","Ultracopier is runnning!");
                              showDelayedPopup("Ultracopier is runnning!",QSystemTrayIcon::Information);
                        }
                        else
                        {
                              DEBUGCONSOLE(10,"UIcon::dispatchParam","The last parameters should a folder if you have more than 4 arguments! Show the online help.");
                              showDelayedPopup("The last parameters should a folder if you have\nmore than 4 arguments! Show the online help.",QSystemTrayIcon::Warning);
                        }
                  }
                  else
                  {
                        bool moveQuery=true;
                        if(argumentsUltracopier.size()>3 ||(QFileInfo(argumentsUltracopier.last()).isDir()))
                        {
                              if(!argumentsUltracopier.last().endsWith('/') && !argumentsUltracopier.last().endsWith('\\'))
                                    argumentsUltracopier.last()+=QDir::separator();
                        }
                        QString theCurrentArgument=argumentsUltracopier.at(0);
                        DEBUGCONSOLE(30,"UIcon::dispatchParam","number of argument: "+QString::number(argumentsUltracopier.size()));
                        for (int i = 0; i < argumentsUltracopier.size(); ++i) {
                              if(QFileInfo(argumentsUltracopier.at(i)).isDir() && !argumentsUltracopier.at(i).endsWith('/') && !argumentsUltracopier.at(i).endsWith('\\'))
                                    argumentsUltracopier[i]+=QDir::separator();
                              DEBUGCONSOLE(90,"UIcon::dispatchParam","argument["+QString::number(i)+"]: "+argumentsUltracopier.at(i));
                        }
                        #if (DEBUG_ULTRACOPIER>0)
                        if(!(theCurrentArgument=="cp" || theCurrentArgument=="Copy" || theCurrentArgument=="mv" || theCurrentArgument=="Move"))
                        {
                              DEBUGCONSOLE(10,"UIcon::dispatchParam","First param note understand!");
                              showDelayedPopup("First param note understand!",QSystemTrayIcon::Warning);
                        }
                        #endif

                        //load here the right copy or move windows
                        Main_window *main=NULL;
                        QString comboBoxGroupWindows;
                        QSettings *theSettings=getSettingsRes();
                        if(theSettings->status()==QSettings::NoError)
                        {
                              theSettings->beginGroup("Interface");
                              if(theSettings->contains("comboBoxGroupWindows"))
                                    comboBoxGroupWindows=theSettings->value("comboBoxGroupWindows").toString();
                              theSettings->endGroup();
                        }
                        if(theCurrentArgument=="cp" || theCurrentArgument=="Copy")
                              moveQuery=false;
                        if(theCurrentArgument=="mv" || theCurrentArgument=="Move")
                              moveQuery=true;
                        //When same source
                        //When same destination
                        //When same source and destination
                        QString destination,source="";
                        if(QFileInfo(argumentsUltracopier.last()).isDir())
                              destination=argumentsUltracopier.last();
                        else
                              destination=QFileInfo(argumentsUltracopier.last()).absoluteDir().path();
                        for (int i=1; i<argumentsUltracopier.size()-1; ++i) {
                              QString source2(argumentsUltracopier.at(i));
                              if(QFileInfo(source2).isDir())
                                    source2=argumentsUltracopier.last();
                              else
                                    source2=QFileInfo(argumentsUltracopier.last()).absoluteDir().path();
                              if(source=="")
                                    source=source2;
                              else if(source!=source2)
                                    source="*";
                        }
                        if(comboBoxGroupWindows==tr("When same source")) //try group copy
                        {
                              int size=theMainWindowCopyMove.size();
                              if(windowIsPreloaded)
                                    size--;
                              for (int i=0; i<size; ++i) {
                                    if(theMainWindowCopyMove.at(i)->getMovingMode()==moveQuery && theMainWindowCopyMove.at(i)->getMainSource()==source)
                                          main=theMainWindowCopyMove.at(i);
                              }
                        }
                        if(comboBoxGroupWindows==tr("When same destination")) //try group copy
                        {
                              int size=theMainWindowCopyMove.size();
                              if(windowIsPreloaded)
                                    size--;
                              DEBUGCONSOLE(90,"UIcon::dispatchParam","destination: "+destination);
                              for (int i=0; i<size; ++i) {
                                    DEBUGCONSOLE(90,"UIcon::dispatchParam","theMainWindowCopyMove.at("+QString::number(i)+")->getMainDestination(): "+theMainWindowCopyMove.at(i)->getMainDestination());
                                    if(theMainWindowCopyMove.at(i)->getMovingMode()==moveQuery && theMainWindowCopyMove.at(i)->getMainDestination()==destination)
                                          main=theMainWindowCopyMove.at(i);
                              }
                        }
                        if(comboBoxGroupWindows==tr("When same source and destination")) //try group copy
                        {
                              int size=theMainWindowCopyMove.size();
                              if(windowIsPreloaded)
                                    size--;
                              for (int i=0; i<size; ++i) {
                                    if(theMainWindowCopyMove.at(i)->getMovingMode()==moveQuery &&
                                       theMainWindowCopyMove.at(i)->getMainSource()==source &&
                                       theMainWindowCopyMove.at(i)->getMainDestination()==destination)
                                          main=theMainWindowCopyMove.at(i);
                              }
                        }
                        if(comboBoxGroupWindows==tr("Always")) //try group copy
                        {
                              int size=theMainWindowCopyMove.size();
                              if(windowIsPreloaded)
                                    size--;
                              for (int i=0; i<size; ++i) {
                                    if(theMainWindowCopyMove.at(i)->getMovingMode()==moveQuery)
                                          main=theMainWindowCopyMove.at(i);
                              }
                        }
                        if(main==NULL) //else use new windows
                        {
                              if(moveQuery)
                                    main = MoveAction();
                              else
                                    main = CopyAction();
                        }
                        else
                        {
                              DEBUGCONSOLE(90,"UIcon::dispatchParam","found compatible copy/move window");
                              main->show();
                        }

                        if(theCurrentArgument=="cp" || theCurrentArgument=="mv")
                        {
                              DEBUGCONSOLE(30,"UIcon::dispatchParam","Open the copy/move window");
                              argumentsUltracopier.removeFirst();
                              setArgumentMainWindow(main,argumentsUltracopier,client,copyId,protocolVersionOfThisQuery);
                        }
                        else if(theCurrentArgument=="Copy" || theCurrentArgument=="Move")
                        {
                              DEBUGCONSOLE(30,"UIcon::dispatchParam","Open the copy window (list mode)");
                              for (int i = 1; i < argumentsUltracopier.size(); ++i) {
                                    if(argumentsUltracopier.at(i).startsWith("*"))
                                    {
                                          //load the file
                                          QFile theListFile(argumentsUltracopier.at(i).right(argumentsUltracopier.at(i).length()-1));
                                          DEBUGCONSOLE(50,"UIcon::dispatchParam","List found: "+theListFile.fileName());
                                          //for after delete the item from the list
                                          argumentsUltracopier.removeAt(i);
                                          if(theListFile.open(QIODevice::ReadOnly))
                                          {
                                                QString content;
                                                QTextStream contentStream(&theListFile);
                                                contentStream.setAutoDetectUnicode(true);
                                                content=contentStream.readAll();
                                                QStringList newList=content.split(QRegExp("\\r{0,1}\\n"));
                                                for (int j = 0; j < newList.size(); ++j) {
                                                      if(newList.at(j)!="")
                                                      {
                                                            DEBUGCONSOLE(90,"UIcon::dispatchParam","insert at "+QString::number(i)+": "+newList.at(j));
                                                            argumentsUltracopier.insert(i++,newList.at(j));
                                                      }
                                                      #if (DEBUG_ULTRACOPIER>0)
                                                      else
                                                      {
                                                            DEBUGCONSOLE(30,"UIcon::dispatchParam","Empty arg for argumentsUltracopier["+QString::number(i)+"]");
                                                      }
                                                      #endif
                                                }
                                                theListFile.close();
                                                #if (DEBUG_ULTRACOPIER>0)
                                                theListFile.copy(giveWritablePath("CopyList/CopyList-"+QString::number(QCoreApplication::applicationPid())+".dat"));
                                                if(theListFile.remove())
                                                      DEBUGCONSOLE(90,"UIcon::dispatchParam","File list successfully removed!");
                                                else
                                                      DEBUGCONSOLE(30,"UIcon::dispatchParam","File list failed to remove!");
                                                #else
                                                      theListFile.remove();
                                                #endif
                                          }
                                          else
                                          {
                                                if(QFile::exists(theListFile.fileName()))
                                                      showDelayedPopup("Copy list file not found",QSystemTrayIcon::Warning);
                                                else
                                                      showDelayedPopup("Copy list file not open in read mode",QSystemTrayIcon::Warning);
                                                DEBUGCONSOLE(10,"UIcon::dispatchParam","The List file cannot be open in read mode: "+theListFile.errorString());
                                                return;
                                          }
                                    }
                              }
                              #if (DEBUG_ULTRACOPIER>0)
                                    DEBUGCONSOLE(30,"UIcon::dispatchParam","number of argument: "+QString::number(argumentsUltracopier.size()));
                                    for (int i = 0; i < argumentsUltracopier.size(); ++i) {
                                          DEBUGCONSOLE(30,"UIcon::dispatchParam","argument["+QString::number(i)+"]: "+argumentsUltracopier.at(i));
                                    }
                              #endif
                              if(argumentsUltracopier.size()>=3)
                              {
                                    argumentsUltracopier.removeFirst();
                                    setArgumentMainWindow(main,argumentsUltracopier,client,copyId,protocolVersionOfThisQuery);
                              }
                              else
                              {
                                    showDelayedPopup("Number of arguments not greater than 3!",QSystemTrayIcon::Warning);
                                    DEBUGCONSOLE(10,"UIcon::dispatchParam","number of arguments not greater than 3!");
                              }
                        }
                  }
            }
      }
}

Here is the call graph for this function:

Here is the caller graph for this function:


Generated by  Doxygen 1.6.0   Back to index