summaryrefslogtreecommitdiff
path: root/noncore/apps/advancedfm/advancedfmMenu.cpp
Side-by-side diff
Diffstat (limited to 'noncore/apps/advancedfm/advancedfmMenu.cpp') (more/less context) (show whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfmMenu.cpp121
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
@@ -12,3 +12,2 @@
#include "advancedfm.h"
-#include "inputDialog.h"
#include "output.h"
@@ -17,2 +16,3 @@
#include <opie/otabwidget.h>
+#include <opie/oprocess.h>
@@ -235,3 +235,3 @@ void AdvancedFm::localDelete() {
QString cmd="rm -rf "+f;
- system( cmd.latin1());
+ startProcess( (const QString)cmd.latin1() );
populateLocalView();
@@ -257,3 +257,2 @@ void AdvancedFm::localDelete() {
file.remove();
- // system( cmd.latin1());
}
@@ -300,3 +299,3 @@ void AdvancedFm::remoteDelete() {
QString cmd="rm -rf "+f;
- system( cmd.latin1());
+ startProcess( (const QString)cmd );
populateRemoteView();
@@ -322,3 +321,2 @@ void AdvancedFm::remoteDelete() {
file.remove();
- // system( cmd.latin1());
}
@@ -825,30 +823,16 @@ void AdvancedFm::runCommand() {
fileDlg->exec();
- QString command;
+ //QString command;
+
if( fileDlg->result() == 1 ) {
- command = fileDlg->LineEdit1->text();
+ qDebug(fileDlg->LineEdit1->text());
+ QStringList command;
+ command << "/bin/sh";
+ command << "-c";
+ command << fileDlg->LineEdit1->text();
Output *outDlg;
- outDlg = new Output(this, tr("AdvancedFm Output"),FALSE);
+ outDlg = new Output( command, this, tr("AdvancedFm Output"), true);
outDlg->showMaximized();
- outDlg->show();
+ outDlg->exec();
qApp->processEvents();
- FILE *fp;
- char line[130];
- sleep(1);
- command +=" 2>&1";
- fp = popen( (const char *) command, "r");
- if ( !fp ) {
- qDebug("Could not execute '" + command + "'! err=%d", fp);
- QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") );
- pclose(fp);
- return;
- } else {
- while ( fgets( line, sizeof line, fp)) {
- QString lineStr = line;
- lineStr=lineStr.left(lineStr.length()-1);
- outDlg->OutputEdit->append(lineStr);
- outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
- }
- }
- pclose(fp);
@@ -872,7 +856,6 @@ void AdvancedFm::runCommandStd() {
fileDlg->exec();
- QString command;
+
if( fileDlg->result() == 1 ) {
qApp->processEvents();
- command = fileDlg->LineEdit1->text() + " &";
- system(command.latin1());
+ startProcess( (const QString)fileDlg->LineEdit1->text().latin1());
}
@@ -887,28 +870,42 @@ void AdvancedFm::fileStatus() {
}
- QString command = " stat -l "+ curFile +" 2>&1";
+
+ QStringList command;
+ command << "/bin/sh";
+ command << "-c";
+ command << "stat -l "+ curFile;
+
Output *outDlg;
- outDlg = new Output(this, tr("AdvancedFm Output"),FALSE);
+ outDlg = new Output( command, this, tr("AdvancedFm Output"), true);
outDlg->showMaximized();
- outDlg->show();
+ outDlg->exec();
qApp->processEvents();
- FILE *fp;
- char line[130];
- sleep(1);
- fp = popen( (const char *) command, "r");
- if ( !fp ) {
- qDebug("Could not execute '" + command + "'! err=%d", fp);
- QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") );
- pclose(fp);
- return;
- } else {
- while ( fgets( line, sizeof line, fp)) {
- outDlg->OutputEdit->append(line);
- outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
- }
- }
- pclose(fp);
+// Output *outDlg;
+// outDlg = new Output(this, tr("AdvancedFm Output"),FALSE);
+// outDlg->showMaximized();
+// outDlg->show();
+// qApp->processEvents();
+
+// FILE *fp;
+// char line[130];
+// sleep(1);
+// fp = popen( (const char *) command, "r");
+// if ( !fp ) {
+// qDebug("Could not execute '" + command + "'! err=%d", fp);
+// QMessageBox::warning( this, "AdvancedFm", tr("command failed!"), tr("&OK") );
+// pclose(fp);
+// return;
+// } else {
+// while ( fgets( line, sizeof line, fp)) {
+// outDlg->OutputEdit->append(line);
+// outDlg->OutputEdit->setCursorPosition(outDlg->OutputEdit->numLines() + 1,0,FALSE);
+
+// }
+
+// }
+// pclose(fp);
}
+
void AdvancedFm::mkDir() {
@@ -950,3 +947,3 @@ void AdvancedFm::mkSym() {
qDebug(cmd);
- system(cmd.latin1() );
+ startProcess( (const QString)cmd );
}
@@ -964,3 +961,3 @@ void AdvancedFm::mkSym() {
qDebug(cmd);
- system(cmd.latin1() );
+ startProcess( (const QString)cmd );
}
@@ -1020 +1017,21 @@ void AdvancedFm::selectAll() {
}
+
+void AdvancedFm::startProcess(const QString & cmd) {
+ QStringList command;
+ OProcess *process;
+ process = new OProcess();
+ connect(process, SIGNAL(processExited(OProcess *)),
+ this, SLOT( processEnded()));
+
+ command << "/bin/sh";
+ command << "-c";
+ command << cmd.latin1();
+ *process << command;
+ if(!process->start(OProcess::NotifyOnExit) )
+ qDebug("could not start process");
+}
+
+void AdvancedFm::processEnded() {
+ populateLocalView();
+ populateRemoteView();
+}