Diffstat (limited to 'noncore/apps/advancedfm/advancedfmMenu.cpp') (more/less context) (show whitespace changes)
-rw-r--r-- | noncore/apps/advancedfm/advancedfmMenu.cpp | 121 |
1 files changed, 69 insertions, 52 deletions
diff --git a/noncore/apps/advancedfm/advancedfmMenu.cpp b/noncore/apps/advancedfm/advancedfmMenu.cpp index f89ad30..0a9f921 100644 --- a/noncore/apps/advancedfm/advancedfmMenu.cpp +++ b/noncore/apps/advancedfm/advancedfmMenu.cpp | |||
@@ -10,11 +10,11 @@ | |||
10 | * (at your option) any later version. * | 10 | * (at your option) any later version. * |
11 | ***************************************************************************/ | 11 | ***************************************************************************/ |
12 | #include "advancedfm.h" | 12 | #include "advancedfm.h" |
13 | #include "inputDialog.h" | ||
14 | #include "output.h" | 13 | #include "output.h" |
15 | #include "filePermissions.h" | 14 | #include "filePermissions.h" |
16 | 15 | ||
17 | #include <opie/otabwidget.h> | 16 | #include <opie/otabwidget.h> |
17 | #include <opie/oprocess.h> | ||
18 | 18 | ||
19 | #include <qpe/lnkproperties.h> | 19 | #include <qpe/lnkproperties.h> |
20 | #include <qpe/qpeapplication.h> | 20 | #include <qpe/qpeapplication.h> |
@@ -233,7 +233,7 @@ void AdvancedFm::localDelete() { | |||
233 | case 0: { | 233 | case 0: { |
234 | f=f.left(f.length()-1); | 234 | f=f.left(f.length()-1); |
235 | QString cmd="rm -rf "+f; | 235 | QString cmd="rm -rf "+f; |
236 | system( cmd.latin1()); | 236 | startProcess( (const QString)cmd.latin1() ); |
237 | populateLocalView(); | 237 | populateLocalView(); |
238 | } | 238 | } |
239 | break; | 239 | break; |
@@ -255,7 +255,6 @@ void AdvancedFm::localDelete() { | |||
255 | QFile file(f); | 255 | QFile file(f); |
256 | if(QFileInfo(myFile).fileName().find("../",0,TRUE)==-1) | 256 | if(QFileInfo(myFile).fileName().find("../",0,TRUE)==-1) |
257 | file.remove(); | 257 | file.remove(); |
258 | // system( cmd.latin1()); | ||
259 | } | 258 | } |
260 | } | 259 | } |
261 | } | 260 | } |
@@ -298,7 +297,7 @@ void AdvancedFm::remoteDelete() { | |||
298 | case 0: { | 297 | case 0: { |
299 | f=f.left(f.length()-1); | 298 | f=f.left(f.length()-1); |
300 | QString cmd="rm -rf "+f; | 299 | QString cmd="rm -rf "+f; |
301 | system( cmd.latin1()); | 300 | startProcess( (const QString)cmd ); |
302 | populateRemoteView(); | 301 | populateRemoteView(); |
303 | } | 302 | } |
304 | break; | 303 | break; |
@@ -320,7 +319,6 @@ void AdvancedFm::remoteDelete() { | |||
320 | QFile file(f); | 319 | QFile file(f); |
321 | if(QFileInfo(myFile).fileName().find("../",0,TRUE)==-1) | 320 | if(QFileInfo(myFile).fileName().find("../",0,TRUE)==-1) |
322 | file.remove(); | 321 | file.remove(); |
323 | // system( cmd.latin1()); | ||
324 | } | 322 | } |
325 | } | 323 | } |
326 | } | 324 | } |
@@ -823,34 +821,20 @@ void AdvancedFm::runCommand() { | |||
823 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 821 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
824 | fileDlg->setInputText(curFile); | 822 | fileDlg->setInputText(curFile); |
825 | fileDlg->exec(); | 823 | fileDlg->exec(); |
826 | QString command; | 824 | //QString command; |
825 | |||
827 | if( fileDlg->result() == 1 ) { | 826 | if( fileDlg->result() == 1 ) { |
828 | command = fileDlg->LineEdit1->text(); | 827 | qDebug(fileDlg->LineEdit1->text()); |
828 | QStringList command; | ||
829 | 829 | ||
830 | command << "/bin/sh"; | ||
831 | command << "-c"; | ||
832 | command << fileDlg->LineEdit1->text(); | ||
830 | Output *outDlg; | 833 | Output *outDlg; |
831 | outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); | 834 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); |
832 | outDlg->showMaximized(); | 835 | outDlg->showMaximized(); |
833 | outDlg->show(); | 836 | outDlg->exec(); |
834 | qApp->processEvents(); | 837 | qApp->processEvents(); |
835 | FILE *fp; | ||
836 | char line[130]; | ||
837 | sleep(1); | ||
838 | command +=" 2>&1"; | ||
839 | fp = popen( (const char *) command, "r"); | ||
840 | if ( !fp ) { | ||
841 | qDebug("Could not execute '" + command + "'! err=%d", fp); | ||
842 | QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") ); | ||
843 | pclose(fp); | ||
844 | return; | ||
845 | } else { | ||
846 | while ( fgets( line, sizeof line, fp)) { | ||
847 | QString lineStr = line; | ||
848 | lineStr=lineStr.left(lineStr.length()-1); | ||
849 | outDlg->OutputEdit->append(lineStr); | ||
850 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | ||
851 | } | ||
852 | } | ||
853 | pclose(fp); | ||
854 | 838 | ||
855 | } | 839 | } |
856 | } | 840 | } |
@@ -870,11 +854,10 @@ void AdvancedFm::runCommandStd() { | |||
870 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); | 854 | fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0); |
871 | fileDlg->setInputText(curFile); | 855 | fileDlg->setInputText(curFile); |
872 | fileDlg->exec(); | 856 | fileDlg->exec(); |
873 | QString command; | 857 | |
874 | if( fileDlg->result() == 1 ) { | 858 | if( fileDlg->result() == 1 ) { |
875 | qApp->processEvents(); | 859 | qApp->processEvents(); |
876 | command = fileDlg->LineEdit1->text() + " &"; | 860 | startProcess( (const QString)fileDlg->LineEdit1->text().latin1()); |
877 | system(command.latin1()); | ||
878 | } | 861 | } |
879 | } | 862 | } |
880 | 863 | ||
@@ -885,32 +868,46 @@ void AdvancedFm::fileStatus() { | |||
885 | } else { | 868 | } else { |
886 | curFile = Remote_View->currentItem()->text(0); | 869 | curFile = Remote_View->currentItem()->text(0); |
887 | } | 870 | } |
888 | QString command = " stat -l "+ curFile +" 2>&1"; | 871 | |
872 | QStringList command; | ||
873 | command << "/bin/sh"; | ||
874 | command << "-c"; | ||
875 | command << "stat -l "+ curFile; | ||
876 | |||
889 | Output *outDlg; | 877 | Output *outDlg; |
890 | outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); | 878 | outDlg = new Output( command, this, tr("AdvancedFm Output"), true); |
891 | outDlg->showMaximized(); | 879 | outDlg->showMaximized(); |
892 | outDlg->show(); | 880 | outDlg->exec(); |
893 | qApp->processEvents(); | 881 | qApp->processEvents(); |
894 | FILE *fp; | ||
895 | char line[130]; | ||
896 | sleep(1); | ||
897 | fp = popen( (const char *) command, "r"); | ||
898 | if ( !fp ) { | ||
899 | qDebug("Could not execute '" + command + "'! err=%d", fp); | ||
900 | QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") ); | ||
901 | pclose(fp); | ||
902 | return; | ||
903 | } else { | ||
904 | while ( fgets( line, sizeof line, fp)) { | ||
905 | outDlg->OutputEdit->append(line); | ||
906 | outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | ||
907 | 882 | ||
908 | } | ||
909 | 883 | ||
910 | } | 884 | // Output *outDlg; |
911 | pclose(fp); | 885 | // outDlg = new Output(this, tr("AdvancedFm Output"),FALSE); |
886 | // outDlg->showMaximized(); | ||
887 | // outDlg->show(); | ||
888 | // qApp->processEvents(); | ||
889 | |||
890 | // FILE *fp; | ||
891 | // char line[130]; | ||
892 | // sleep(1); | ||
893 | // fp = popen( (const char *) command, "r"); | ||
894 | // if ( !fp ) { | ||
895 | // qDebug("Could not execute '" + command + "'! err=%d", fp); | ||
896 | // QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") ); | ||
897 | // pclose(fp); | ||
898 | // return; | ||
899 | // } else { | ||
900 | // while ( fgets( line, sizeof line, fp)) { | ||
901 | // outDlg->OutputEdit->append(line); | ||
902 | // outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE); | ||
903 | |||
904 | // } | ||
905 | |||
906 | // } | ||
907 | // pclose(fp); | ||
912 | } | 908 | } |
913 | 909 | ||
910 | |||
914 | void AdvancedFm::mkDir() { | 911 | void AdvancedFm::mkDir() { |
915 | if (TabWidget->getCurrentTab() == 0) | 912 | if (TabWidget->getCurrentTab() == 0) |
916 | localMakDir(); | 913 | localMakDir(); |
@@ -948,7 +945,7 @@ void AdvancedFm::mkSym() { | |||
948 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); | 945 | if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1); |
949 | cmd = "ln -s "+curFile+" "+destName; | 946 | cmd = "ln -s "+curFile+" "+destName; |
950 | qDebug(cmd); | 947 | qDebug(cmd); |
951 | system(cmd.latin1() ); | 948 | startProcess( (const QString)cmd ); |
952 | } | 949 | } |
953 | populateRemoteView(); | 950 | populateRemoteView(); |
954 | TabWidget->setCurrentTab(1); | 951 | TabWidget->setCurrentTab(1); |
@@ -962,7 +959,7 @@ void AdvancedFm::mkSym() { | |||
962 | 959 | ||
963 | cmd = "ln -s "+curFile+" "+destName; | 960 | cmd = "ln -s "+curFile+" "+destName; |
964 | qDebug(cmd); | 961 | qDebug(cmd); |
965 | system(cmd.latin1() ); | 962 | startProcess( (const QString)cmd ); |
966 | } | 963 | } |
967 | populateLocalView(); | 964 | populateLocalView(); |
968 | TabWidget->setCurrentTab(0); | 965 | TabWidget->setCurrentTab(0); |
@@ -1018,3 +1015,23 @@ void AdvancedFm::selectAll() { | |||
1018 | Remote_View->setSelected( Remote_View->firstChild(),false); | 1015 | Remote_View->setSelected( Remote_View->firstChild(),false); |
1019 | } | 1016 | } |
1020 | } | 1017 | } |
1018 | |||
1019 | void AdvancedFm::startProcess(const QString & cmd) { | ||
1020 | QStringList command; | ||
1021 | OProcess *process; | ||
1022 | process = new OProcess(); | ||
1023 | connect(process, SIGNAL(processExited(OProcess *)), | ||
1024 | this, SLOT( processEnded())); | ||
1025 | |||
1026 | command << "/bin/sh"; | ||
1027 | command << "-c"; | ||
1028 | command << cmd.latin1(); | ||
1029 | *process << command; | ||
1030 | if(!process->start(OProcess::NotifyOnExit) ) | ||
1031 | qDebug("could not start process"); | ||
1032 | } | ||
1033 | |||
1034 | void AdvancedFm::processEnded() { | ||
1035 | populateLocalView(); | ||
1036 | populateRemoteView(); | ||
1037 | } | ||