00001 /*************************************************************************** 00002 * SpikeStream Application * 00003 * Copyright (C) 2007 by David Gamez * 00004 * david@davidgamez.eu * 00005 * Version 0.1 * 00006 * * 00007 * This program is free software; you can redistribute it and/or modify * 00008 * it under the terms of the GNU General Public License as published by * 00009 * the Free Software Foundation; either version 2 of the License, or * 00010 * (at your option) any later version. * 00011 * * 00012 * This program is distributed in the hope that it will be useful, * 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00015 * GNU General Public License for more details. * 00016 * * 00017 * You should have received a copy of the GNU General Public License * 00018 * along with this program; if not, write to the * 00019 * Free Software Foundation, Inc., * 00020 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * 00021 ***************************************************************************/ 00022 00023 #ifndef SCRIPTRUNNER_H 00024 #define SCRIPTRUNNER_H 00025 00026 //Qt includes 00027 #include <qprocess.h> 00028 #include <qstring.h> 00029 #include <qstringlist.h> 00030 #include <qdialog.h> 00031 #include <qtextedit.h> 00032 #include <qpushbutton.h> 00033 00034 00035 //--------------------------- Script Runner -------------------------------- 00036 /*! Runs scripts in the /scripts directory. Can pass parameters to them 00037 but script is assumed to be self contained. Use the program 'expect' 00038 within the script if interaction is required with an external program. */ 00039 //-------------------------------------------------------------------------- 00040 00041 class ScriptRunner : public QDialog { 00042 Q_OBJECT 00043 00044 public: 00045 ScriptRunner(QWidget* parent, QString scriptName, QString mainWorkDir); 00046 ~ScriptRunner(); 00047 bool processError(); 00048 bool processRunning(); 00049 00050 00051 private slots: 00052 void okButtonPressed(); 00053 void processExited(); 00054 void readFromStderr(); 00055 void readFromStdout(); 00056 void stopButtonPressed(); 00057 00058 00059 private: 00060 //========================== VARIABLES =========================== 00061 /*! The main directory of the application. This should contain 00062 containing the scripts in a scripts subdirectory.*/ 00063 QString workingDirectory; 00064 00065 /*! Flag to record errors executing the script.*/ 00066 bool procErr; 00067 00068 /*! The process that executes the script.*/ 00069 QProcess* process; 00070 00071 /*! QTextEdit to display the output from the script.*/ 00072 QTextEdit* scriptMessages; 00073 00074 /*! Hides the dialog. This is disabled whilst the script is running.*/ 00075 QPushButton* okButton; 00076 00077 00078 //========================= METHODS =============================== 00079 /*! Declare copy constructor private so it cannot be used inadvertently.*/ 00080 ScriptRunner (const ScriptRunner&); 00081 00082 /*! Declare assignment private so it cannot be used inadvertently.*/ 00083 ScriptRunner operator = (const ScriptRunner&); 00084 00085 void runScript(const char* scriptName); 00086 void runScript(QString scriptName); 00087 void runScript(QString scriptName, QStringList scriptParameters); 00088 bool stopScript(); 00089 00090 }; 00091 00092 00093 #endif//SCRIPTRUNNER_H 00094 00095
1.4.4