summaryrefslogtreecommitdiff
authorllornkcor <llornkcor>2002-11-16 05:28:00 (UTC)
committer llornkcor <llornkcor>2002-11-16 05:28:00 (UTC)
commit9591a32654e5189841b9a6d60e7bf235b1b0fa4b (patch) (side-by-side diff)
tree8a8251b3af82ad830d5d7bc85cd39aea68e505d8
parentb17b2274c200403da25a994ed9d8ba4856d725c0 (diff)
downloadopie-9591a32654e5189841b9a6d60e7bf235b1b0fa4b.zip
opie-9591a32654e5189841b9a6d60e7bf235b1b0fa4b.tar.gz
opie-9591a32654e5189841b9a6d60e7bf235b1b0fa4b.tar.bz2
moved input to output, switched all systems calls to OProcess. got rid of popen
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--noncore/apps/advancedfm/advancedfm.h3
-rw-r--r--noncore/apps/advancedfm/advancedfm.pro4
-rw-r--r--noncore/apps/advancedfm/advancedfmMenu.cpp215
-rw-r--r--noncore/apps/advancedfm/inputDialog.cpp44
-rw-r--r--noncore/apps/advancedfm/inputDialog.h35
-rw-r--r--noncore/apps/advancedfm/output.cpp142
-rw-r--r--noncore/apps/advancedfm/output.h32
7 files changed, 274 insertions, 201 deletions
diff --git a/noncore/apps/advancedfm/advancedfm.h b/noncore/apps/advancedfm/advancedfm.h
index 7bccce9..9948255 100644
--- a/noncore/apps/advancedfm/advancedfm.h
+++ b/noncore/apps/advancedfm/advancedfm.h
@@ -140,15 +140,18 @@ protected slots:
void copySameDir();
void currentPathComboActivated(const QString &);
void fillCombo(const QString &);
bool copyFile( const QString & , const QString & );
void move();
void fileStatus();
void doAbout();
void doBeam();
void fileBeamFinished( Ir *);
private:
QTimer menuTimer;
+ void startProcess(const QString &);
+private slots:
+ void processEnded();
};
#endif // ADVANCEDFM_H
diff --git a/noncore/apps/advancedfm/advancedfm.pro b/noncore/apps/advancedfm/advancedfm.pro
index bda2fdf..0e037a1 100644
--- a/noncore/apps/advancedfm/advancedfm.pro
+++ b/noncore/apps/advancedfm/advancedfm.pro
@@ -1,16 +1,16 @@
TEMPLATE = app
CONFIG += qt warn_on release
-HEADERS = advancedfm.h inputDialog.h filePermissions.h output.h
-SOURCES = advancedfm.cpp advancedfmData.cpp advancedfmMenu.cpp inputDialog.cpp filePermissions.cpp output.cpp main.cpp
+HEADERS = advancedfm.h filePermissions.h output.h
+SOURCES = advancedfm.cpp advancedfmData.cpp advancedfmMenu.cpp filePermissions.cpp output.cpp main.cpp
TARGET = advancedfm
INCLUDEPATH += $(OPIEDIR)/include
DEPENDPATH += $(OPIEDIR)/include
DESTDIR = $(OPIEDIR)/bin
LIBS += -lqpe -lopie
TRANSLATIONS = ../../../i18n/de/advancedfm.ts \
../../../i18n/en/advancedfm.ts \
../../../i18n/es/advancedfm.ts \
../../../i18n/fr/advancedfm.ts \
../../../i18n/hu/advancedfm.ts \
../../../i18n/ja/advancedfm.ts \
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
@@ -1,29 +1,29 @@
/***************************************************************************
AdvancedFm.cpp
-------------------
** Created: Sat Mar 9 23:33:09 2002
copyright : (C) 2002 by ljp
email : ljp@llornkcor.com
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
***************************************************************************/
#include "advancedfm.h"
-#include "inputDialog.h"
#include "output.h"
#include "filePermissions.h"
#include <opie/otabwidget.h>
+#include <opie/oprocess.h>
#include <qpe/lnkproperties.h>
#include <qpe/qpeapplication.h>
#include <qpe/qpemenubar.h>
#include <qpe/qpetoolbar.h>
#include <qpe/resource.h>
#include <qpe/qcopenvelope_qws.h>
#include <qpe/applnk.h>
#include <qpe/ir.h>
#include <qmessagebox.h>
#include <qmultilineedit.h>
@@ -224,47 +224,46 @@ void AdvancedFm::localDelete() {
QString f = currentDir.canonicalPath();
if(f.right(1).find("/",0,TRUE) == -1)
f+="/";
f+=myFile;
if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) {
switch ( QMessageBox::warning(this,tr("Delete Directory?"),tr("Really delete\n")+f+
"\nand all it's contents ?"
,tr("Yes"),tr("No"),0,0,1) ) {
case 0: {
f=f.left(f.length()-1);
QString cmd="rm -rf "+f;
- system( cmd.latin1());
+ startProcess( (const QString)cmd.latin1() );
populateLocalView();
}
break;
case 1:
// exit
break;
};
} else {
if(doMsg) {
switch ( QMessageBox::warning(this,tr("Delete"),tr("Really delete\n")+f
+" ?",tr("Yes"),tr("No"),0,0,1) ) {
case 1:
return;
break;
};
}
QString cmd="rm "+f;
QFile file(f);
if(QFileInfo(myFile).fileName().find("../",0,TRUE)==-1)
file.remove();
- // system( cmd.latin1());
}
}
}
populateLocalView();
}
void AdvancedFm::remoteDelete() {
QStringList curFileList = getPath();
bool doMsg=true;
int count=curFileList.count();
if( count > 0) {
if(count > 1 ){
@@ -289,47 +288,46 @@ void AdvancedFm::remoteDelete() {
myFile = myFile.left(myFile.find(" -> ",0,TRUE));
QString f = currentRemoteDir.canonicalPath();
if(f.right(1).find("/",0,TRUE) == -1)
f+="/";
f+=myFile;
if(QDir(f).exists() && !QFileInfo(f).isSymLink() ) {
switch ( QMessageBox::warning(this,tr("Delete Directory"),tr("Really delete\n")+f+
"\nand all it's contents ?",
tr("Yes"),tr("No"),0,0,1) ) {
case 0: {
f=f.left(f.length()-1);
QString cmd="rm -rf "+f;
- system( cmd.latin1());
+ startProcess( (const QString)cmd );
populateRemoteView();
}
break;
case 1:
// exit
break;
};
} else {
if(doMsg) {
switch ( QMessageBox::warning(this,tr("Delete"),tr("Really delete\n")+f
+" ?",tr("Yes"),tr("No"),0,0,1) ) {
case 1:
return;
break;
};
}
QString cmd="rm "+f;
QFile file(f);
if(QFileInfo(myFile).fileName().find("../",0,TRUE)==-1)
file.remove();
- // system( cmd.latin1());
}
}
}
populateRemoteView();
}
void AdvancedFm::localRename() {
QString curFile = Local_View->currentItem()->text(0);
qDebug("currentItem "+curFile);
if( curFile !="../") {
InputDialog *fileDlg;
fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0);
@@ -801,182 +799,181 @@ bool AdvancedFm::copyFile( const QString & dest, const QString & src ) {
success = FALSE;
}
// Set file permissions
if( stat( (const char *) src, &status ) == 0 ){
chmod( (const char *) dest, status.st_mode );
}
return success;
}
void AdvancedFm::runCommand() {
- QString curFile;
- if (TabWidget->getCurrentTab() == 0) {
- if( Local_View->currentItem())
- curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0);
- } else {
- if(Remote_View->currentItem())
- curFile = currentRemoteDir.canonicalPath() + "/"+Remote_View->currentItem()->text(0);
- }
-
- InputDialog *fileDlg;
- fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
- fileDlg->setInputText(curFile);
- fileDlg->exec();
- QString command;
- if( fileDlg->result() == 1 ) {
- command = fileDlg->LineEdit1->text();
-
- Output *outDlg;
- outDlg = new Output(this, tr("AdvancedFm Output"),FALSE);
- outDlg->showMaximized();
- outDlg->show();
- 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;
+ QString curFile;
+ if (TabWidget->getCurrentTab() == 0) {
+ if( Local_View->currentItem())
+ curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0);
} 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);
- }
+ if(Remote_View->currentItem())
+ curFile = currentRemoteDir.canonicalPath() + "/"+Remote_View->currentItem()->text(0);
}
- pclose(fp);
- }
+ InputDialog *fileDlg;
+ fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
+ fileDlg->setInputText(curFile);
+ fileDlg->exec();
+ //QString command;
+
+ if( fileDlg->result() == 1 ) {
+ qDebug(fileDlg->LineEdit1->text());
+ QStringList command;
+
+ command << "/bin/sh";
+ command << "-c";
+ command << fileDlg->LineEdit1->text();
+ Output *outDlg;
+ outDlg = new Output( command, this, tr("AdvancedFm Output"), true);
+ outDlg->showMaximized();
+ outDlg->exec();
+ qApp->processEvents();
+
+ }
}
void AdvancedFm::runCommandStd() {
QString curFile;
if (TabWidget->getCurrentTab() == 0) {
if( Local_View->currentItem())
curFile = currentDir.canonicalPath() +"/"+ Local_View->currentItem()->text(0);
} else {
if(Remote_View->currentItem())
curFile = currentRemoteDir.canonicalPath() +"/"
+ Remote_View->currentItem()->text(0);
}
InputDialog *fileDlg;
fileDlg = new InputDialog(this,tr("Run Command"),TRUE, 0);
fileDlg->setInputText(curFile);
fileDlg->exec();
- QString command;
+
if( fileDlg->result() == 1 ) {
- qApp->processEvents();
- command = fileDlg->LineEdit1->text() + " &";
- system(command.latin1());
+ qApp->processEvents();
+ startProcess( (const QString)fileDlg->LineEdit1->text().latin1());
}
}
void AdvancedFm::fileStatus() {
QString curFile;
if (TabWidget->getCurrentTab() == 0) {
curFile = Local_View->currentItem()->text(0);
} else {
curFile = Remote_View->currentItem()->text(0);
}
- QString command = " stat -l "+ curFile +" 2>&1";
- 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);
- }
+ QStringList command;
+ command << "/bin/sh";
+ command << "-c";
+ command << "stat -l "+ curFile;
- }
- pclose(fp);
+ Output *outDlg;
+ outDlg = new Output( command, this, tr("AdvancedFm Output"), true);
+ outDlg->showMaximized();
+ outDlg->exec();
+ qApp->processEvents();
+
+
+// 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() {
if (TabWidget->getCurrentTab() == 0)
localMakDir();
else
remoteMakDir();
}
void AdvancedFm::rn() {
if (TabWidget->getCurrentTab() == 0)
localRename();
else
remoteRename();
}
void AdvancedFm::del() {
if (TabWidget->getCurrentTab() == 0)
localDelete();
else
remoteDelete();
}
void AdvancedFm::mkSym() {
- QString cmd;
- QStringList curFileList = getPath();
- if( curFileList.count() > 0) {
+ QString cmd;
+ QStringList curFileList = getPath();
+ if( curFileList.count() > 0) {
- if (TabWidget->getCurrentTab() == 0) {
- for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
+ if (TabWidget->getCurrentTab() == 0) {
+ for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
- QString destName = currentRemoteDir.canonicalPath()+"/"+(*it);
- if(destName.right(1) == "/") destName = destName.left( destName.length() -1);
- QString curFile = currentDir.canonicalPath()+"/"+(*it);
- if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1);
- cmd = "ln -s "+curFile+" "+destName;
- qDebug(cmd);
- system(cmd.latin1() );
- }
- populateRemoteView();
- TabWidget->setCurrentTab(1);
- } else {
- for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
+ QString destName = currentRemoteDir.canonicalPath()+"/"+(*it);
+ if(destName.right(1) == "/") destName = destName.left( destName.length() -1);
+ QString curFile = currentDir.canonicalPath()+"/"+(*it);
+ if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1);
+ cmd = "ln -s "+curFile+" "+destName;
+ qDebug(cmd);
+ startProcess( (const QString)cmd );
+ }
+ populateRemoteView();
+ TabWidget->setCurrentTab(1);
+ } else {
+ for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
- QString destName = currentDir.canonicalPath()+"/"+(*it);
- if(destName.right(1) == "/") destName = destName.left( destName.length() -1);
- QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it);
- if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1);
+ QString destName = currentDir.canonicalPath()+"/"+(*it);
+ if(destName.right(1) == "/") destName = destName.left( destName.length() -1);
+ QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it);
+ if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1);
- cmd = "ln -s "+curFile+" "+destName;
- qDebug(cmd);
- system(cmd.latin1() );
- }
- populateLocalView();
- TabWidget->setCurrentTab(0);
+ cmd = "ln -s "+curFile+" "+destName;
+ qDebug(cmd);
+ startProcess( (const QString)cmd );
+ }
+ populateLocalView();
+ TabWidget->setCurrentTab(0);
+ }
}
- }
}
void AdvancedFm::doBeam() {
Ir ir;
if(!ir.supported()){
} else {
QStringList curFileList = getPath();
if( curFileList.count() > 0) {
if (TabWidget->getCurrentTab() == 0) {
for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
@@ -1009,12 +1006,32 @@ void AdvancedFm::fileBeamFinished( Ir *) {
}
void AdvancedFm::selectAll() {
if (TabWidget->getCurrentTab() == 0) {
Local_View->selectAll(true);
Local_View->setSelected( Local_View->firstChild(),false);
} else {
Remote_View->selectAll(true);
Remote_View->setSelected( Remote_View->firstChild(),false);
}
}
+
+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();
+}
diff --git a/noncore/apps/advancedfm/inputDialog.cpp b/noncore/apps/advancedfm/inputDialog.cpp
deleted file mode 100644
index 5af0f72..0000000
--- a/noncore/apps/advancedfm/inputDialog.cpp
+++ b/dev/null
@@ -1,44 +0,0 @@
-/****************************************************************************
- inputDialog.cpp
- -------------------
-** Created: Sat Mar 9 23:33:09 2002
- copyright : (C) 2002 by ljp
- email : ljp@llornkcor.com
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- ***************************************************************************/
-
-#include "inputDialog.h"
-
-#include <qlineedit.h>
-#include <qlayout.h>
-#include <qvariant.h>
-#include <qtooltip.h>
-#include <qwhatsthis.h>
-
-
-InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
- : QDialog( parent, name, modal, fl )
-{
- if ( !name )
- setName( "InputDialog" );
- resize( 234, 50 );
- setMaximumSize( QSize( 240, 50 ) );
- setCaption( tr(name ) );
-
- LineEdit1 = new QLineEdit( this, "LineEdit1" );
- LineEdit1->setGeometry( QRect( 10, 10, 216, 22 ) );
-}
-
-InputDialog::~InputDialog()
-{
- inputText = LineEdit1->text();
-
-}
-
-void InputDialog::setInputText(const QString &string)
-{
-LineEdit1->setText( string);
-}
diff --git a/noncore/apps/advancedfm/inputDialog.h b/noncore/apps/advancedfm/inputDialog.h
deleted file mode 100644
index 114a3a8..0000000
--- a/noncore/apps/advancedfm/inputDialog.h
+++ b/dev/null
@@ -1,35 +0,0 @@
-/***************************************************************************
- inputDialog.h
- -------------------
-** Created: Sat Mar 9 23:33:09 2002
- copyright : (C) 2002 by ljp
- email : ljp@llornkcor.com
- * This program is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
- ***************************************************************************/
-#ifndef INPUTDIALOG_H
-#define INPUTDIALOG_H
-
-#include <qvariant.h>
-#include <qdialog.h>
-class QVBoxLayout;
-class QHBoxLayout;
-class QGridLayout;
-class QLineEdit;
-
-class InputDialog : public QDialog
-{
- Q_OBJECT
-
-public:
- InputDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
- ~InputDialog();
- QString inputText;
- QLineEdit* LineEdit1;
- void setInputText(const QString &);
-
-};
-
-#endif // INPUTDIALOG_H
diff --git a/noncore/apps/advancedfm/output.cpp b/noncore/apps/advancedfm/output.cpp
index 82e78a7..946d038 100644
--- a/noncore/apps/advancedfm/output.cpp
+++ b/noncore/apps/advancedfm/output.cpp
@@ -1,32 +1,37 @@
/****************************************************************************
** outputEdit.cpp
**
** Copyright: Fri Apr 12 15:12:58 2002 L.J. Potter <ljp@llornkcor.com>
****************************************************************************/
#include "output.h"
-#include "inputDialog.h"
+
+#include <opie/oprocess.h>
#include <qpe/filemanager.h>
#include <qpe/qpeapplication.h>
#include <qpe/applnk.h>
+#include <qmessagebox.h>
+#include <qstringlist.h>
#include <qfile.h>
-
+#include <qcstring.h>
#include <qlineedit.h>
#include <qmultilineedit.h>
#include <qpushbutton.h>
#include <qlayout.h>
#include <qvariant.h>
+#include <errno.h>
+
/* XPM */
static char * filesave_xpm[] = {
"16 16 78 1",
" c None",
". c #343434",
"+ c #A0A0A0",
"@ c #565656",
"# c #9E9E9E",
"$ c #525252",
"% c #929292",
"& c #676767",
"* c #848484",
@@ -107,55 +112,82 @@ static char * filesave_xpm[] = {
" [}|;;;;;;;{12$",
" #34-55;;;;678$+",
" 90ab=c;dd;e1fg ",
" [ahij((kbl0mn$ ",
" op^q^^7r&]s/$+ ",
"@btu;vbwxy]zAB ",
"CzDEvEv;;DssF$ ",
"G.H{E{E{IxsJ$+ ",
" +...vEKxzLM ",
" +...z]n$ ",
" +... "};
-Output::Output( QWidget* parent, const char* name, bool modal, WFlags fl )
+Output::Output( const QStringList commands, QWidget* parent, const char* name, bool modal, WFlags fl)
: QDialog( parent, name, modal, fl )
{
- if ( !name )
- setName( "Output" );
+ QStringList cmmds;
+// cmmds=QStringList::split( " ", commands, false);
+ cmmds=commands;
+// qDebug("count %d", cmmds.count());
+ if ( !name )
+ setName( tr("Output"));
resize( 196, 269 );
setCaption( name );
+
OutputLayout = new QGridLayout( this );
- OutputLayout->setSpacing( 6 );
- OutputLayout->setMargin( 11 );
+ OutputLayout->setSpacing( 2);
+ OutputLayout->setMargin( 2);
QPushButton *docButton;
- docButton = new QPushButton( QPixmap(( const char** ) filesave_xpm ) ,"",this,"saveButton");
- docButton->setFixedSize( QSize( 20, 20 ) );
- connect( docButton,SIGNAL(released()),this,SLOT( saveOutput() ));
-// docButton->setFlat(TRUE);
- OutputLayout->addMultiCellWidget( docButton, 0,0,3,3 );
-
+ docButton = new QPushButton( QPixmap(( const char** ) filesave_xpm ) ,"",this,"saveButton");
+ docButton->setFixedSize( QSize( 20, 20 ) );
+ connect( docButton,SIGNAL(released()),this,SLOT( saveOutput() ));
+ // docButton->setFlat(TRUE);
+ OutputLayout->addMultiCellWidget( docButton, 0,0,3,3 );
OutputEdit = new QMultiLineEdit( this, "OutputEdit" );
OutputLayout->addMultiCellWidget( OutputEdit, 1,1,0,3 );
+ proc = new OProcess();
+
+ connect(proc, SIGNAL(processExited(OProcess *)),
+ this, SLOT( processFinished()));
+
+ connect(proc, SIGNAL(receivedStdout(OProcess *, char *, int)),
+ this, SLOT(commandStdout(OProcess *, char *, int)));
+
+ connect(proc, SIGNAL(receivedStderr(OProcess *, char *, int)),
+ this, SLOT(commandStderr(OProcess *, char *, int)));
+
+// connect( , SIGNAL(received(const QByteArray &)),
+// this, SLOT(commandStdin(const QByteArray &)));
+
+// * proc << commands.latin1();
+ for ( QStringList::Iterator it = cmmds.begin(); it != cmmds.end(); ++it ) {
+ qDebug( "%s", (*it).latin1() );
+ * proc << (*it).latin1();
+ }
+ if(!proc->start(OProcess::NotifyOnExit, OProcess::All)) {
+
+ OutputEdit->append("Process could not start");
+ OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE);
+ perror("Error: ");
+ QString errorMsg="Error\n"+(QString)strerror(errno);
+ OutputEdit->append( errorMsg);
+ OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE);
+ }
}
-/*
- * Destroys the object and frees any allocated resources
- */
-Output::~Output()
-{
- // no need to delete child widgets, Qt does it all for us
+Output::~Output() {
}
void Output::saveOutput() {
InputDialog *fileDlg;
fileDlg = new InputDialog(this,tr("Save output to file (name only)"),TRUE, 0);
fileDlg->exec();
if( fileDlg->result() == 1 ) {
QString filename = QPEApplication::documentDir();
if(filename.right(1).find('/') == -1)
filename+="/";
QString name = fileDlg->LineEdit1->text();
@@ -166,15 +198,85 @@ void Output::saveOutput() {
f.open( IO_WriteOnly);
if( f.writeBlock( OutputEdit->text(), qstrlen( OutputEdit->text()) ) != -1) {
DocLnk lnk;
lnk.setName(name); //sets file name
lnk.setFile(filename); //sets File property
lnk.setType("text/plain");
if(!lnk.writeLink()) {
qDebug("Writing doclink did not work");
}
} else
qWarning("Could not write file");
f.close();
-
}
}
+
+void Output::commandStdout(OProcess*, char *buffer, int buflen) {
+ qWarning("received stdout %d bytes", buflen);
+
+// QByteArray data(buflen);
+// data.fill(*buffer, buflen);
+// for (uint i = 0; i < data.count(); i++ ) {
+// printf("%c", buffer[i] );
+// }
+// printf("\n");
+
+ QString lineStr = buffer;
+ lineStr=lineStr.left(lineStr.length()-1);
+ OutputEdit->append(lineStr);
+ OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE);
+}
+
+
+void Output::commandStdin( const QByteArray &data) {
+ qWarning("received stdin %d bytes", data.size());
+ // recieved data from the io layer goes to sz
+ proc->writeStdin(data.data(), data.size());
+}
+
+void Output::commandStderr(OProcess*, char *buffer, int buflen) {
+ qWarning("received stderrt %d bytes", buflen);
+
+ QString lineStr = buffer;
+// lineStr=lineStr.left(lineStr.length()-1);
+ OutputEdit->append(lineStr);
+ OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE);
+}
+
+void Output::processFinished() {
+
+ delete proc;
+ OutputEdit->append( "\nFinished\n");
+ OutputEdit->setCursorPosition( OutputEdit->numLines() + 1,0,FALSE);
+// close();
+// disconnect( layer(), SIGNAL(received(const QByteArray &)),
+// this, SLOT(commandStdin(const QByteArray &)));
+}
+
+//==============================
+
+InputDialog::InputDialog( QWidget* parent, const char* name, bool modal, WFlags fl )
+ : QDialog( parent, name, modal, fl )
+{
+ if ( !name )
+ setName( "InputDialog" );
+ resize( 234, 50 );
+ setMaximumSize( QSize( 240, 50 ) );
+ setCaption( tr(name ) );
+
+ LineEdit1 = new QLineEdit( this, "LineEdit1" );
+ LineEdit1->setGeometry( QRect( 10, 10, 216, 22 ) );
+ connect(LineEdit1,SIGNAL(returnPressed()),this,SLOT(returned() ));
+}
+
+InputDialog::~InputDialog() {
+ inputText = LineEdit1->text();
+}
+
+void InputDialog::setInputText(const QString &string) {
+ LineEdit1->setText( string);
+}
+
+void InputDialog::returned() {
+ inputText = LineEdit1->text();
+ this->accept();
+}
diff --git a/noncore/apps/advancedfm/output.h b/noncore/apps/advancedfm/output.h
index c1e48da..199a684 100644
--- a/noncore/apps/advancedfm/output.h
+++ b/noncore/apps/advancedfm/output.h
@@ -2,34 +2,64 @@
** Form interface generated from reading ui file 'outputEdit.ui'
**
** Created: Fri Apr 12 15:12:44 2002
** by: The User Interface Compiler (uic)
**
** WARNING! All changes made in this file will be lost!
****************************************************************************/
#ifndef OUTPUT_H
#define OUTPUT_H
#include <qvariant.h>
#include <qdialog.h>
+#include <qcstring.h>
+#include <qstringlist.h>
+#include <qlineedit.h>
+#include <qwhatsthis.h>
+
+#include <opie/oprocess.h>
+
class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class QMultiLineEdit;
class Output : public QDialog
{
Q_OBJECT
public:
- Output( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
+ Output(const QStringList commands=0, QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
~Output();
QMultiLineEdit* OutputEdit;
protected:
QGridLayout* OutputLayout;
+ OProcess *proc;
protected slots:
void saveOutput();
+ void commandStdout(OProcess*, char *, int);
+ void commandStdin(const QByteArray &);
+ void commandStderr(OProcess*, char *, int);
+ void processFinished();
+ private:
+ QString cmmd;
+
+};
+
+class InputDialog : public QDialog
+{
+ Q_OBJECT
+
+public:
+ InputDialog( QWidget* parent = 0, const char* name = 0, bool modal = FALSE, WFlags fl = 0 );
+ ~InputDialog();
+ QString inputText;
+ QLineEdit* LineEdit1;
+ void setInputText(const QString &);
+private slots:
+ void returned();
+
};
#endif // OUTPUT_H