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
@@ -1,154 +1,157 @@
/***************************************************************************
advancedfm.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 ADVANCEDFM_H
#define ADVANCEDFM_H
#define QTOPIA_INTERNAL_FSLP // to get access to fileproperties
#define QT_QWS_OPIE
//#include <opie/otabwidget.h>
#include <qpe/ir.h>
#include <qvariant.h>
#include <qdialog.h>
#include <qmainwindow.h>
#include <qstringlist.h>
#include <qdir.h>
#include <qstring.h>
#include <qpoint.h>
#include <qtimer.h>
class OTabWidget;
class QVBoxLayout;
class QHBoxLayout;
class QGridLayout;
class QComboBox;
class QListView;
class QListviewItem;
class QLabel;
class QProgressBar;
class QSpinBox;
class QTabWidget;
class QWidget;
class QPEToolBar;
class QPEMenuBar;
class QPopupMenu;
class QFile;
class QListViewItem;
class QLineEdit;
//class QPushButton;
class QToolButton;
class Ir;
class AdvancedFm : public QMainWindow
{
Q_OBJECT
public:
AdvancedFm();
~AdvancedFm();
OTabWidget *TabWidget;
// QTabWidget *TabWidget;
QWidget *tab, *tab_2, *tab_3;
QListView *Local_View, *Remote_View;
QLineEdit *currentPathEdit;
QPopupMenu *fileMenu, *localMenu, *remoteMenu, *viewMenu;
QToolButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton;
// QPushButton *homeButton, *docButton, *cdUpButton, *sdButton, *cfButton, *qpeDirButton;
QDir currentDir, currentRemoteDir;
QComboBox *currentPathCombo;
QString filterStr;
QListViewItem * item;
bool b;
QStringList fileSystemTypeList, fsList;
int currentServerConfig;
protected slots:
void selectAll();
void addToDocs();
void doLocalCd();
void doRemoteCd();
// void copy();
void mkDir();
void del();
void rn();
void populateLocalView();
void populateRemoteView();
void showHidden();
void showMenuHidden();
void showRemoteHidden();
void writeConfig();
void readConfig();
void localListClicked(QListViewItem *);
void remoteListClicked(QListViewItem *);
void localListPressed( int, QListViewItem *, const QPoint&, int);
void remoteListPressed( int, QListViewItem *, const QPoint&, int);
void localMakDir();
void localDelete();
void remoteMakDir();
void remoteDelete();
/* bool remoteDirList(const QString &); */
/* bool remoteChDir(const QString &); */
void tabChanged(QWidget*);
void cleanUp();
void remoteRename();
void localRename();
void runThis();
void runText();
void filePerms();
void doProperties();
void runCommand();
void runCommandStd();
QStringList getPath();
void mkSym();
void switchToLocalTab();
void switchToRemoteTab();
protected:
bool zaurusDevice;
QGridLayout *tabLayout, *tabLayout_2, *tabLayout_3;
QStringList remoteDirPathStringList, localDirPathStringList;
void init();
void initConnections();
void keyReleaseEvent( QKeyEvent *);
QString getFileSystemType(const QString &);
QString getDiskSpace(const QString &);
void parsetab(const QString &fileName);
QString checkDiskSpace(const QString &);
protected slots:
void showFileMenu();
void cancelMenuTimer();
void homeButtonPushed();
void docButtonPushed();
void SDButtonPushed();
void CFButtonPushed();
void QPEButtonPushed();
void upDir();
void currentPathComboChanged();
void copy();
void copyAs();
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,24 +1,24 @@
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 \
../../../i18n/ko/advancedfm.ts \
../../../i18n/no/advancedfm.ts \
../../../i18n/pl/advancedfm.ts \
../../../i18n/pt/advancedfm.ts \
../../../i18n/pt_BR/advancedfm.ts \
../../../i18n/sl/advancedfm.ts \
../../../i18n/zh_CN/advancedfm.ts \
../../../i18n/zh_TW/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,515 +1,513 @@
/***************************************************************************
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>
#include <qstring.h>
#include <qlayout.h>
#include <qpixmap.h>
#include <qcombobox.h>
#include <qpopupmenu.h>
#include <qtabwidget.h>
#include <qtoolbutton.h>
#include <qtabwidget.h>
#include <qlineedit.h>
#include <qlistview.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/stat.h>
#include <dirent.h>
void AdvancedFm::doLocalCd() {
localListClicked( Local_View->currentItem());
}
void AdvancedFm::doRemoteCd() {
localListClicked( Remote_View->currentItem());
}
void AdvancedFm::showMenuHidden() {
if (b) {
currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
fileMenu->setItemChecked( fileMenu->idAt(0),TRUE);
// b=FALSE;
} else {
currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
currentRemoteDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
fileMenu->setItemChecked( fileMenu->idAt(0),FALSE);
// b=TRUE;
}
populateLocalView();
populateRemoteView();
// if(TabWidget->getCurrentTab() == 0)
// showHidden();
// else
// showRemoteHidden();
// if(b) qDebug("<<<<<<<<<<<<<<<<<<<<<<<<<<<< true");
if(b) b = false; else b = true;
}
void AdvancedFm::showHidden() {
if (b) {
currentDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
// fileMenu->setItemChecked( fileMenu->idAt(0),TRUE);
// b=FALSE;
} else {
currentDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
// fileMenu->setItemChecked( fileMenu->idAt(0),FALSE);
// b=TRUE;
}
populateLocalView();
}
void AdvancedFm::showRemoteHidden() {
if (b) {
currentRemoteDir.setFilter( QDir::Files | QDir::Dirs | QDir::Hidden | QDir::All);
// b=TRUE;
} else {
currentRemoteDir.setFilter( QDir::Files | QDir::Dirs/* | QDir::Hidden*/ | QDir::All);
// b=FALSE;
}
populateRemoteView();
}
void AdvancedFm::runThis() {
QString fs;
if (TabWidget->getCurrentTab() == 0) {
QString curFile = Local_View->currentItem()->text(0);
if(curFile != "../") {
fs= getFileSystemType((const QString &) currentDir.canonicalPath());
QFileInfo fileInfo( currentDir.canonicalPath()+"/"+curFile);
qDebug( fileInfo.owner());
if( (fileInfo.permission( QFileInfo::ExeUser)
| fileInfo.permission( QFileInfo::ExeGroup)
| fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) {
| fs == "vfat" && fileInfo.filePath().contains("/bin") ) {
QCopEnvelope e("QPE/System", "execute(QString)" );
e << curFile;
} else {
curFile = currentDir.canonicalPath()+"/"+curFile;
DocLnk nf(curFile);
QString execStr = nf.exec();
qDebug( execStr);
if( execStr.isEmpty() ) {
} else {
nf.execute();
}
}
}
} else {
QString curFile = Remote_View->currentItem()->text(0);
if(curFile != "../") {
fs= getFileSystemType((const QString &) currentRemoteDir.canonicalPath());
qDebug("Filesystemtype is "+fs);
QFileInfo fileInfo( currentRemoteDir.canonicalPath()+"/"+curFile);
if( (fileInfo.permission( QFileInfo::ExeUser)
| fileInfo.permission( QFileInfo::ExeGroup)
| fileInfo.permission( QFileInfo::ExeOther)) // & fs.find("vfat",0,TRUE) == -1) {
| fs == "vfat" && fileInfo.filePath().contains("/bin") ) {
QCopEnvelope e("QPE/System", "execute(QString)" );
e << curFile;
} else {
curFile = currentRemoteDir.canonicalPath()+"/"+curFile;
DocLnk nf(curFile);
QString execStr = nf.exec();
qDebug(execStr);
if( execStr.isEmpty() ) {
} else {
nf.execute();
}
}
}
}
}
void AdvancedFm::runText() {
if (TabWidget->getCurrentTab() == 0) {
QString curFile = Local_View->currentItem()->text(0);
if(curFile != "../") {
curFile = currentDir.canonicalPath()+"/"+curFile;
QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" );
e << curFile;
}
} else {
QString curFile = Remote_View->currentItem()->text(0);
if(curFile != "../") {
curFile = currentRemoteDir.canonicalPath()+"/"+curFile;
DocLnk nf(curFile);
QCopEnvelope e("QPE/Application/textedit", "setDocument(QString)" );
e << curFile;
}
}
}
void AdvancedFm::localMakDir() {
InputDialog *fileDlg;
fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
fileDlg->exec();
if( fileDlg->result() == 1 ) {
QString filename = fileDlg->LineEdit1->text();
currentDir.mkdir( currentDir.canonicalPath()+"/"+filename);
}
populateLocalView();
}
void AdvancedFm::remoteMakDir() {
InputDialog *fileDlg;
fileDlg = new InputDialog(this,tr("Make Directory"),TRUE, 0);
fileDlg->exec();
if( fileDlg->result() == 1 ) {
QString filename = fileDlg->LineEdit1->text();
currentRemoteDir.mkdir( currentRemoteDir.canonicalPath()+"/"+filename);
}
populateRemoteView();
}
void AdvancedFm::localDelete() {
QStringList curFileList = getPath();
bool doMsg=true;
int count=curFileList.count();
if( count > 0) {
if(count > 1 ){
QString msg;
msg=tr("Really delete\n%1 files?").arg(count);
switch ( QMessageBox::warning(this,tr("Delete"),msg
,tr("Yes"),tr("No"),0,0,1) ) {
case 0:
doMsg=false;
break;
case 1:
return;
break;
};
}
QString myFile;
for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
myFile = (*it);
if( myFile.find(" -> ",0,TRUE) != -1)
myFile = myFile.left( myFile.find(" -> ",0,TRUE));
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 ){
QString msg;
msg=tr("Really delete\n%1 files?").arg(count);
switch ( QMessageBox::warning(this,tr("Delete"),msg
,tr("Yes"),tr("No"),0,0,1) ) {
case 0:
doMsg=false;
break;
case 1:
return;
break;
};
}
QString myFile;
for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
myFile = (*it);
if(myFile.find(" -> ",0,TRUE) != -1)
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);
fileDlg->setInputText((const QString &)curFile);
fileDlg->exec();
if( fileDlg->result() == 1 ) {
QString oldname = currentDir.canonicalPath() + "/" + curFile;
QString newName = currentDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();
//+".playlist";
if( rename(oldname.latin1(), newName.latin1())== -1)
QMessageBox::message(tr("Note"),tr("Could not rename"));
}
populateLocalView();
}
}
void AdvancedFm::remoteRename()
{
QString curFile = Remote_View->currentItem()->text(0);
if( curFile !="../") {
InputDialog *fileDlg;
fileDlg = new InputDialog(this,tr("Rename"),TRUE, 0);
fileDlg->setInputText((const QString &)curFile);
fileDlg->exec();
if( fileDlg->result() == 1 ) {
QString oldname = currentRemoteDir.canonicalPath() + "/" + curFile;
QString newName = currentRemoteDir.canonicalPath() + "/" + fileDlg->LineEdit1->text();
//+".playlist";
if( rename(oldname.latin1(), newName.latin1())== -1)
QMessageBox::message(tr("Note"),tr("Could not rename"));
}
populateRemoteView();
}
}
void AdvancedFm::filePerms() {
QStringList curFileList = getPath();
QString filePath;
if (TabWidget->getCurrentTab() == 0) {
filePath = currentDir.canonicalPath()+"/";
} else {
filePath= currentRemoteDir.canonicalPath()+"/";
}
for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
filePermissions *filePerm;
filePerm = new filePermissions(this, "Permissions",true,0,(const QString &)(filePath+*it));
filePerm->showMaximized();
filePerm->exec();
if( filePerm)
delete filePerm;
}
if (TabWidget->getCurrentTab() == 0) {
populateLocalView();
} else {
populateRemoteView();
}
}
void AdvancedFm::doProperties() {
#if defined(QT_QWS_OPIE)
QStringList curFileList = getPath();
QString filePath;
if (TabWidget->getCurrentTab() == 0) {
filePath = currentDir.canonicalPath()+"/";
} else {
filePath= currentRemoteDir.canonicalPath()+"/";
}
qDebug("%d",curFileList.count());
for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
qDebug((filePath+*it));
DocLnk lnk( (filePath+*it));
LnkProperties prop( &lnk );
prop.showMaximized();
prop.exec();
}
#endif
}
void AdvancedFm::upDir() {
if (TabWidget->getCurrentTab() == 0) {
QString current = currentDir.canonicalPath();
QDir dir(current);
dir.cdUp();
current = dir.canonicalPath();
chdir( current.latin1() );
currentDir.cd( current, TRUE);
populateLocalView();
update();
} else {
QString current = currentRemoteDir.canonicalPath();
QDir dir(current);
dir.cdUp();
current = dir.canonicalPath();
chdir( current.latin1() );
currentRemoteDir.cd( current, TRUE);
populateRemoteView();
update();
}
}
void AdvancedFm::copy() {
qApp->processEvents();
QStringList curFileList = getPath();
bool doMsg=true;
int count=curFileList.count();
if( count > 0) {
if(count > 1 ){
QString msg;
msg=tr("Really copy\n%1 files?").arg(count);
switch ( QMessageBox::warning(this,tr("Delete"),msg
,tr("Yes"),tr("No"),0,0,1) ) {
case 0:
doMsg=false;
break;
case 1:
return;
break;
};
}
QString curFile, item, destFile;
if (TabWidget->getCurrentTab() == 0) {
for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
item=(*it);
if(item.find("->",0,TRUE)) //symlink
item = item.left(item.find("->",0,TRUE));
destFile = currentRemoteDir.canonicalPath()+"/"+ item;
qDebug("Destination file is "+destFile);
curFile = currentDir.canonicalPath()+"/"+ item;
qDebug("CurrentFile file is " + curFile);
QFile f(destFile);
if( f.exists()) {
if(doMsg) {
switch ( QMessageBox::warning(this,tr("File Exists!"),
item+tr("\nexists. Ok to overwrite?"),
tr("Yes"),tr("No"),0,0,1) ) {
case 1:
return;
break;
};
}
f.remove();
}
if(!copyFile(destFile, curFile) ) {
QMessageBox::message("AdvancedFm","Could not copy\n"+curFile +"to\n"+destFile);
return;
}
}
populateRemoteView();
TabWidget->setCurrentTab(1);
} else {
for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
item= (*it);
if(item.find("->",0,TRUE)) //symlink
item = item.left(item.find("->",0,TRUE));
destFile = currentDir.canonicalPath()+"/"+ item;
qDebug("Destination file is "+destFile);
curFile = currentRemoteDir.canonicalPath()+"/"+ item;;
qDebug("CurrentFile file is " + curFile);
QFile f(destFile);
if( f.exists()) {
switch ( QMessageBox::warning(this,tr("File Exists!"),
item+tr("\nexists. Ok to overwrite?"),
tr("Yes"),tr("No"),0,0,1) ) {
case 1:
return;
break;
};
@@ -621,400 +619,419 @@ void AdvancedFm::copyAs() {
void AdvancedFm::copySameDir() {
qApp->processEvents();
QStringList curFileList = getPath();
QString curFile, item, destFile;
InputDialog *fileDlg;
if (TabWidget->getCurrentTab() == 0) {
for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
item=(*it);
curFile = currentDir.canonicalPath()+"/"+ item;
fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0);
fileDlg->setInputText((const QString &) destFile );
fileDlg->exec();
if( fileDlg->result() == 1 ) {
QString filename = fileDlg->LineEdit1->text();
destFile = currentDir.canonicalPath()+"/"+filename;
QFile f(destFile);
if( f.exists()) {
switch (QMessageBox::warning(this,tr("Delete"),
destFile+tr(" already exists\nDo you really want to delete it?"),
tr("Yes"),tr("No"),0,0,1) ) {
case 0:
f.remove();
break;
case 1:
return;
break;
};
}
if(!copyFile(destFile, curFile) ) {
QMessageBox::message("AdvancedFm",tr("Could not copy\n")
+curFile +tr("to\n")+destFile);
return;
}
qDebug("copy "+curFile+" as "+destFile);
}
delete fileDlg;
}
populateLocalView();
} else {
for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
item=(*it);
curFile = currentRemoteDir.canonicalPath()+"/"+ item;
fileDlg = new InputDialog(this,tr("Copy ")+curFile+tr(" As"),TRUE, 0);
fileDlg->setInputText((const QString &) destFile);
fileDlg->exec();
if( fileDlg->result() == 1 ) {
QString filename = fileDlg->LineEdit1->text();
destFile = currentRemoteDir.canonicalPath()+"/"+filename;
QFile f(destFile);
if( f.exists()) {
switch ( QMessageBox::warning(this,tr("Delete"),
destFile+tr(" already exists\nDo you really want to delete it?"),
tr("Yes"),tr("No"),0,0,1) ) {
case 0:
f.remove();
break;
case 1:
return;
break;
};
}
if(!copyFile(destFile, curFile) ) {
QMessageBox::message("AdvancedFm",tr("Could not copy\n")
+curFile +tr("to\n")+destFile);
return;
}
qDebug("copy "+curFile+" as "+destFile);
}
delete fileDlg;
}
populateRemoteView();
}
}
void AdvancedFm::move() {
qApp->processEvents();
QStringList curFileList = getPath();
if( curFileList.count() > 0) {
QString curFile, destFile, item;
if (TabWidget->getCurrentTab() == 0) {
for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
item=(*it);
QString destFile = currentRemoteDir.canonicalPath();
if(destFile.right(1).find("/",0,TRUE) == -1)
destFile+="/";
destFile += item;
curFile = currentDir.canonicalPath();
qDebug("Destination file is "+destFile);
if(curFile.right(1).find("/",0,TRUE) == -1)
curFile +="/";
curFile+= item;
qDebug("CurrentFile file is " + curFile);
QFile f( curFile);
if( f.exists()) {
if(!copyFile( destFile, curFile) ) {
QMessageBox::message(tr("Note"),tr("Could not move\n")+curFile);
return;
} else
QFile::remove(curFile);
}
}
TabWidget->setCurrentTab(1);
} else { //view 2
for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
item = (*it);
QString destFile = currentDir.canonicalPath();
if(destFile.right(1).find("/",0,TRUE) == -1)
destFile+="/";
destFile += item;
qDebug("Destination file is "+destFile);
curFile = currentRemoteDir.canonicalPath();
if(curFile.right(1).find("/",0,TRUE) == -1)
curFile +="/";
curFile+= item;
qDebug("CurrentFile file is " + curFile);
QFile f( curFile);
if( f.exists()) {
if(!copyFile( destFile, curFile) ) {
QMessageBox::message(tr("Note"),tr("Could not move\n") + curFile);
return;
} else
QFile::remove( curFile);
}
TabWidget->setCurrentTab(0);
}
}
populateRemoteView();
populateLocalView();
}
}
bool AdvancedFm::copyFile( const QString & dest, const QString & src ) {
char bf[ 50000 ];
int bytesRead;
bool success = TRUE;
struct stat status;
QFile s( src );
QFile d( dest );
if( s.open( IO_ReadOnly | IO_Raw ) && d.open( IO_WriteOnly | IO_Raw ) ) {
while( (bytesRead = s.readBlock( bf, sizeof( bf ) )) == sizeof( bf ) ) {
if( d.writeBlock( bf, sizeof( bf ) ) != sizeof( bf ) ){
success = FALSE;
break;
}
}
if( success && (bytesRead > 0) ){
d.writeBlock( bf, bytesRead );
}
} else {
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 ) {
QString curFile = currentDir.canonicalPath()+"/"+(*it);
if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1);
Ir *file = new Ir(this, "IR");
connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * )));
file->send( curFile, curFile );
}
} else {
for ( QStringList::Iterator it = curFileList.begin(); it != curFileList.end(); ++it ) {
QString curFile = currentRemoteDir.canonicalPath()+"/"+(*it);
if( curFile.right(1) == "/") curFile = curFile.left( curFile.length() -1);
Ir *file = new Ir(this, "IR");
connect(file, SIGNAL(done(Ir*)), this, SLOT( fileBeamFinished( Ir * )));
file->send( curFile, curFile );
}
}
}
}
}
void AdvancedFm::fileBeamFinished( Ir *) {
QMessageBox::message( tr("Advancedfm Beam out"), tr("Ir sent.") ,tr("Ok") );
}
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,180 +1,282 @@
/****************************************************************************
** 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",
"= c #666666",
"- c #D8D8D8",
"; c #FFFFFF",
"> c #DBDBDB",
", c #636363",
"' c #989898",
") c #2D2D2D",
"! c #909090",
"~ c #AEAEAE",
"{ c #EAEAEA",
"] c #575757",
"^ c #585858",
"/ c #8A8A8A",
"( c #828282",
"_ c #6F6F6F",
": c #C9C9C9",
"< c #050505",
"[ c #292929",
"} c #777777",
"| c #616161",
"1 c #3A3A3A",
"2 c #BEBEBE",
"3 c #2C2C2C",
"4 c #7C7C7C",
"5 c #F6F6F6",
"6 c #FCFCFC",
"7 c #6B6B6B",
"8 c #959595",
"9 c #4F4F4F",
"0 c #808080",
"a c #767676",
"b c #818181",
"c c #B8B8B8",
"d c #FBFBFB",
"e c #F9F9F9",
"f c #CCCCCC",
"g c #030303",
"h c #737373",
"i c #7A7A7A",
"j c #7E7E7E",
"k c #6A6A6A",
"l c #FAFAFA",
"m c #505050",
"n c #9D9D9D",
"o c #333333",
"p c #7B7B7B",
"q c #787878",
"r c #696969",
"s c #494949",
"t c #555555",
"u c #949494",
"v c #E6E6E6",
"w c #424242",
"x c #515151",
"y c #535353",
"z c #3E3E3E",
"A c #D4D4D4",
"B c #0C0C0C",
"C c #353535",
"D c #474747",
"E c #ECECEC",
"F c #919191",
"G c #7D7D7D",
"H c #000000",
"I c #404040",
"J c #858585",
"K c #323232",
"L c #D0D0D0",
"M c #1C1C1C",
" ...+ ",
" @#$%&..+ ",
" .*=-;;>,..+ ",
" ')!~;;;;;;{]..",
" ^/(-;;;;;;;_:<",
" [}|;;;;;;;{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();
filename+="text/plain/"+name;
qDebug(filename);
QFile f(filename);
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
@@ -1,35 +1,65 @@
/****************************************************************************
** 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