diff options
author | Fabian Schillinger | 2010-11-05 02:03:45 +0100 |
---|---|---|
committer | Fabian Schillinger | 2010-11-05 02:03:45 +0100 |
commit | 98d31dde1d8c220bd3602d4751c24508a54e3fab (patch) | |
tree | 3921ed97778912a00263728dab105f35f6d1f8e6 /src | |
parent | [PVSMGRTOUCH] resetall bug fixed (diff) | |
download | pvs-98d31dde1d8c220bd3602d4751c24508a54e3fab.tar.gz pvs-98d31dde1d8c220bd3602d4751c24508a54e3fab.tar.xz pvs-98d31dde1d8c220bd3602d4751c24508a54e3fab.zip |
Process start/stop/view functionality
Cleanup
write to logfiles if start/stop/view of processes failed
added some prompts
stop more then one process at the same time
Diffstat (limited to 'src')
-rw-r--r-- | src/core/pvsConnectionManager.cpp | 76 | ||||
-rw-r--r-- | src/gui/mainWindow.cpp | 75 | ||||
-rw-r--r-- | src/gui/mainWindow.h | 11 | ||||
-rw-r--r-- | src/gui/processWidget.cpp | 56 | ||||
-rw-r--r-- | src/gui/processWidget.h | 3 | ||||
-rw-r--r-- | src/gui/processesDialog.cpp | 26 | ||||
-rw-r--r-- | src/gui/processesDialog.h | 2 | ||||
-rw-r--r-- | src/gui/processesStartDialog.cpp | 53 | ||||
-rw-r--r-- | src/gui/processesStartDialog.h | 18 | ||||
-rw-r--r-- | src/gui/ui/processWidget.ui | 2 | ||||
-rw-r--r-- | src/gui/ui/processesStartDialog.ui | 32 | ||||
-rwxr-xr-x | src/pvs.cpp | 30 | ||||
-rwxr-xr-x | src/pvs.h | 3 |
13 files changed, 262 insertions, 125 deletions
diff --git a/src/core/pvsConnectionManager.cpp b/src/core/pvsConnectionManager.cpp index db302c4..d1442dd 100644 --- a/src/core/pvsConnectionManager.cpp +++ b/src/core/pvsConnectionManager.cpp @@ -226,33 +226,69 @@ void PVSConnectionManager::onCommand(PVSMsg command) QString id = int2String(command.getSndID()); if (message.startsWith("START")) { - QString msgcontent = message.remove(0,6); - if (msgcontent.startsWith("ERROR")) - { - ConsoleLog writeError("[Client: " + id + ", PROCESS] could not start: " +msgcontent.remove(0,6)); - } - else + message.remove(0,6); + if (message.startsWith("ERROR")) { - //ConsoleLog writeLine(QString("[Client: " + id + ", PROCESS] started: " +msgcontent)); + int e = string2Int(message.remove(0,6)); + message.remove(0,2); + switch (e) + { + case 0: + ConsoleLog writeError("[Client: " + id + ", PROCESS] could not start: "+message+" is missing or insufficient permissions"); + break; + case 1: + ConsoleLog writeError("[Client: " + id + ", PROCESS] "+message+" crashed"); + break; + case 2: + ConsoleLog writeError("[Client: " + id + ", PROCESS] "+message+" timed out"); + break; + case 3: + ConsoleLog writeError("[Client: " + id + ", PROCESS] "+message+" read error"); + break; + case 4: + ConsoleLog writeError("[Client: " + id + ", PROCESS] "+message+" write error"); + break; + default: + ConsoleLog writeError("[Client: " + id + ", PROCESS] "+message+": unknown error"); + break; + } } } - if (message.startsWith("STOP")) - { - QString msgcontent = message.remove(0,5); - if (msgcontent.startsWith("ERROR")) - { - ConsoleLog writeError("[Client: " + id + ", PROCESS] could not stop: " +msgcontent.remove(0,6)); - } - else - { - //ConsoleLog writeLine(QString("[Client: " + id + ", PROCESS] stopped: " +msgcontent)); - } + else if (message.startsWith("STOP")) + { + message.remove(0,5); + if (message.startsWith("ERROR")) + { + int e = string2Int(message.remove(0,6)); + message.remove(0,2); + switch (e) + { + case 0: + ConsoleLog writeError("[Client: " + id + ", PROCESS] could not stop: "+message+" is missing or insufficient permissions"); + break; + case 1: + ConsoleLog writeError("[Client: " + id + ", PROCESS] "+message+" crashed"); + break; + case 2: + ConsoleLog writeError("[Client: " + id + ", PROCESS] "+message+" timed out"); + break; + case 3: + ConsoleLog writeError("[Client: " + id + ", PROCESS] "+message+" read error"); + break; + case 4: + ConsoleLog writeError("[Client: " + id + ", PROCESS] "+message+" write error"); + break; + default: + ConsoleLog writeError("[Client: " + id + ", PROCESS] "+message+": unknown error"); + break; + } + } } - if (message.startsWith("SHOW")) + else if (message.startsWith("SHOW")) { QString msgcontent = message.remove(0,5); if (msgcontent.startsWith("ERROR")) - ConsoleLog writeError("[Client: " + id + ", PROCESS] could not show processes: " +msgcontent.remove(0,6)); + ConsoleLog writeError("[Client: " + id + ", PROCESS] could not show processes."); else if (msgcontent.startsWith("clear")) tmp->clearProcessesVector(); else if (msgcontent.startsWith("finished")) diff --git a/src/gui/mainWindow.cpp b/src/gui/mainWindow.cpp index b6878e8..e044470 100644 --- a/src/gui/mainWindow.cpp +++ b/src/gui/mainWindow.cpp @@ -68,6 +68,8 @@ MainWindow::MainWindow(QWidget *parent) : _aboutDialog = new AboutDialog(this); + displayedClientNameEnum = 0; + PVSConnectionManager::getManager(); //set the maximum width for list content @@ -112,8 +114,6 @@ MainWindow::MainWindow(QWidget *parent) : connect(ui->actionProjection, SIGNAL(triggered()), this, SLOT(projecttoolbar())); connect(ui->actionUnprojection, SIGNAL(triggered()), this, SLOT(unprojecttoolbar())); connect(ui->actionDozent, SIGNAL(triggered()), this, SLOT(setdozenttoolbar())); - connect(ui->actionShowProcesses, SIGNAL(triggered()), this, SLOT(showProcesses())); - connect(ui->actionStartProcess, SIGNAL(triggered()), this, SLOT(startProcess())); // Ui specific settings @@ -770,57 +770,44 @@ void MainWindow::closeUp() } } -/* Perform some action if actionShowProcesses button was pressed - * - */ +// Perform some action if actionShowProcesses button was pressed void MainWindow::showProcesses() { - std::list<QString>* selectedClients = - MainWindow::getConnectionList()->getSelectedClients(); - if (selectedClients->size() >= 1) - { - ProcessDialog procDialog; - procDialog.exec(); - - } - else - { - QString - message = - QString( - tr( - "This operation can only be performed if you have selected at least one Client!")); - QMessageBox::information(this, "PVS", message); - } - + ProcessDialog procShowDialog(0,displayedClientNameEnum); + procShowDialog.exec(); } -/* Perform some action if actionStartProcess button was pressed - * - */ +// Perform some action if actionStartProcess button was pressed void MainWindow::startProcess() { std::list<QString>* selectedClients = MainWindow::getConnectionList()->getSelectedClients(); if (selectedClients->size() >= 1) { - // do stuff - /*PVSClient * pvsClient = - PVSConnectionManager::getManager()->getClientFromIp( - selectedClients->front().toStdString().c_str());*/ - - ProcessesStartDialog procD; - QString myString = NULL; - int result = procD.exec(); - - if (result == 1) + ProcessesStartDialog procStartDialog; + procToStart = ""; + int result = procStartDialog.exec(); + if (result == 1) //if result == 1 we clicked send on our button then + //procToStart is set to the text that was given in our messageEdit { - myString = MainWindow::getWindow()->getProcessesDialog(); - if(!myString.isEmpty()) - MainWindow::getConnectionWindow()->commandStations("STARTPROCESS",myString); + std::list<QString>::iterator itSelected; + for (itSelected = selectedClients->begin(); itSelected != selectedClients->end(); + itSelected++) + { + std::list<PVSClient*> listAll = + PVSConnectionManager::getManager()->getConnections(); + for (std::list<PVSClient*>::iterator itAll = listAll.begin(); + itAll != listAll.end(); itAll++) + { + if ((*itSelected) == (*itAll)->getIp()) + { + (*itAll)->sendMessage(PVSCOMMAND, "STARTPROCESS", procToStart); + break; + } + } + } } - } else { @@ -880,6 +867,7 @@ void MainWindow::createProfile() void MainWindow::showusername() { + displayedClientNameEnum = 2; MainWindow::getConnectionList()->setColumnHidden(2, false); MainWindow::getConnectionList()->setColumnHidden(0, true); MainWindow::getConnectionList()->setColumnHidden(1, true); @@ -887,6 +875,7 @@ void MainWindow::showusername() void MainWindow::showname() { + displayedClientNameEnum = 0; MainWindow::getConnectionList()->setColumnHidden(0, false); MainWindow::getConnectionList()->setColumnHidden(1, true); MainWindow::getConnectionList()->setColumnHidden(2, true); @@ -894,6 +883,7 @@ void MainWindow::showname() void MainWindow::showip() { + displayedClientNameEnum = 1; MainWindow::getConnectionList()->setColumnHidden(1, false); MainWindow::getConnectionList()->setColumnHidden(2, true); MainWindow::getConnectionList()->setColumnHidden(0, true); @@ -1293,6 +1283,11 @@ void MainWindow::configureNetwork() } } +int MainWindow::getDisplayedClientNameEnum() +{ + return displayedClientNameEnum; +} + MainWindow* MainWindow::myself = NULL; ConnectionList* MainWindow::conList = NULL; ConnectionWindow* MainWindow::conWin = NULL; diff --git a/src/gui/mainWindow.h b/src/gui/mainWindow.h index 28f82f7..671bf38 100644 --- a/src/gui/mainWindow.h +++ b/src/gui/mainWindow.h @@ -96,8 +96,8 @@ public: void setMsgDialog(QString msgd){msgDialog = msgd;}; QString getMsgDialog(){return msgDialog;}; - void setProcessesDialog(QString procd){procDialog = procd;}; - QString getProcessesDialog(){return procDialog;}; + void setProcessesDialog(QString procd){procToStart = procd;}; + QString getProcessesDialog(){return procToStart;}; bool isLockAllStatus() { @@ -106,8 +106,6 @@ public: void appendLogMsg(); - - protected: void closeEvent(QCloseEvent *e); void changeEvent(QEvent *e); @@ -128,6 +126,8 @@ private: QString _sessionName; QString _profilName; + int displayedClientNameEnum; //to tell if username, loginname or ip is shown in clientList + QStringList _chatListClients; @@ -139,7 +139,7 @@ private: AboutDialog *_aboutDialog; QString msgDialog; - QString procDialog; + QString procToStart; bool bgimage; bool locked, locked1; bool force_square; @@ -186,6 +186,7 @@ public slots: void startChatDialog(); void showProcesses(); void startProcess(); + int getDisplayedClientNameEnum(); private slots: void onToggleLog(bool showtime); diff --git a/src/gui/processWidget.cpp b/src/gui/processWidget.cpp index 9b59b2a..d61b42c 100644 --- a/src/gui/processWidget.cpp +++ b/src/gui/processWidget.cpp @@ -28,10 +28,11 @@ ProcessWidget::ProcessWidget(QWidget *parent, PVSClient *cl): client = cl; connect( prowui->startButton, SIGNAL( clicked()), this, SLOT( startProcess())); - connect( prowui->refreshButton, SIGNAL( clicked()), this, SLOT( refrProcessList())); + connect( prowui->refreshButton, SIGNAL( clicked()), this, SLOT( resendProcessList())); connect( prowui->stopButton, SIGNAL( clicked()), this, SLOT( stopProcess())); connect( client, SIGNAL( processVectorReady(bool)), this, SLOT( refrProcessList())); + //tell client we want to see his processes sendCommand("SHOWPROCESSES", ""); } @@ -39,7 +40,7 @@ void ProcessWidget::startProcess() { QMessageBox::StandardButton start = QMessageBox::question(0, tr("PVS Start Process"), tr("Do you want to start the process: ") + prowui->processLineEdit->text() + - tr(" on User '") + client->getDesktopName() + tr("' ?"), + tr(" on this Client?"), QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Ok); if (start == QMessageBox::Ok) @@ -50,15 +51,23 @@ void ProcessWidget::startProcess() prowui->processLineEdit->clear(); } +void ProcessWidget::resendProcessList() +{ + sendCommand("SHOWPROCESSES", ""); +} + + void ProcessWidget::refrProcessList() { + //remove every item of our list for(int i=prowui->processTable->rowCount(); i == 0; i--) { prowui->processTable->removeRow(i); } prowui->processTable->setRowCount(0); - QVector<QString> processes = client->getProcessesVector(); + //read every entry of the vector - split it - and put it to the list + QVector<QString> processes = client->getProcessesVector(); for (int i=0; i<processes.size(); i++) { prowui->processTable->setRowCount(i+1); @@ -68,6 +77,7 @@ void ProcessWidget::refrProcessList() prowui->processTable->setItem(i,j,new QTableWidgetItem(processesList.at(j),0)); } } + //select row 0 prowui->processTable->selectRow(0); } @@ -75,15 +85,51 @@ void ProcessWidget::stopProcess() { if (prowui->processTable->rowCount() > 0) { + //get a list of all selected items + QList<QTableWidgetItem *> selectedItems = prowui->processTable->selectedItems(); + QList<int> rows; + for (int i=0;i<selectedItems.length();i++) + { + //only add rows one time + if (rows.indexOf(selectedItems.at(i)->row()) < 0) + rows.append(selectedItems.at(i)->row()); + } + //append names of processes + QString processesMessage = ""; + for (int i=0;i<rows.size();i++) + { + if (i==0) + processesMessage.append(QString(tr(" "))); + else + processesMessage.append(QString(tr(","))); + processesMessage.append(prowui->processTable->item(rows.at(i),1)->text()); + processesMessage.append(QString(tr(" "))); + } + + QMessageBox::StandardButton start = QMessageBox::question(0, + tr("PVS Start Process"), tr("Do you want to stop the process(es):") + processesMessage + + tr("on this Client?"), + QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Ok); + if (start == QMessageBox::Ok) + { + //send KILLPROCESS for every row + for (int i=0;i<rows.size();i++) + { + sendCommand("KILLPROCESS", prowui->processTable->item(rows.at(i),0)->text()); + } + } + //tell client to update his list + sendCommand("SHOWPROCESSES", ""); + /* QMessageBox::StandardButton start = QMessageBox::question(0, tr("PVS Start Process"), tr("Do you want to stop the process: ") + prowui->processTable->item(prowui->processTable->currentRow(),1)->text() + - tr(" on User '") + client->getDesktopName() + tr("' ?"), + tr(" on this Client?"), QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Ok); if (start == QMessageBox::Ok) { sendCommand("KILLPROCESS", prowui->processTable->item(prowui->processTable->currentRow(),0)->text()); sendCommand("SHOWPROCESSES", ""); - } + }*/ } } diff --git a/src/gui/processWidget.h b/src/gui/processWidget.h index 7e7eb72..788c9e6 100644 --- a/src/gui/processWidget.h +++ b/src/gui/processWidget.h @@ -17,7 +17,7 @@ class ProcessWidget: public QWidget public: ProcessWidget(QWidget *parent, PVSClient *client); ~ ProcessWidget(); - QAbstractItemModel *model; + public slots: void refrProcessList(); @@ -29,6 +29,7 @@ private: private slots: void startProcess(); void stopProcess(); + void resendProcessList(); void sendCommand(QString ident, QString message); }; diff --git a/src/gui/processesDialog.cpp b/src/gui/processesDialog.cpp index cda76ea..49535d5 100644 --- a/src/gui/processesDialog.cpp +++ b/src/gui/processesDialog.cpp @@ -1,5 +1,5 @@ /* -# Copyright (c) 2009 - OpenSLX Project, Computer Center University of Freiburg +# Copyright (c) 2010 - OpenSLX Project, Computer Center University of Freiburg # # This program is free software distributed under the GPL version 2. # See http://openslx.org/COPYING @@ -17,9 +17,8 @@ #include "processesDialog.h" #include "ui_processesDialog.h" #include <src/gui/processWidget.h> -//#include <src/gui/mainWindow.h> -ProcessDialog::ProcessDialog(QDialog *parent) : +ProcessDialog::ProcessDialog(QDialog *parent, int displayedClientNameEnum) : QDialog(parent), procui(new Ui::ProcessesDialog) { @@ -28,6 +27,7 @@ ProcessDialog::ProcessDialog(QDialog *parent) : tWidget = new QTabWidget; procui->grLayout->addWidget(tWidget); + //if we click on another tab we refresh the list of this client connect( tWidget, SIGNAL( currentChanged(int)), this, SLOT( currChanged())); std::list<PVSClient*> listAll = @@ -35,15 +35,19 @@ ProcessDialog::ProcessDialog(QDialog *parent) : for (std::list<PVSClient*>::iterator it = listAll.begin(); it != listAll.end(); it++) { - if (*it == NULL || (*it)->getConnectionFrame() == NULL) continue; - if ((*it)->getConnectionFrame()->getFrame() && - /*!(*it)->getConnectionFrame()->getFrame()->isDozent() &&*/ - (*it)->getVNCConnection()) + //display ip/login name/user name the same way we do in our clientlist + switch (displayedClientNameEnum) + { + case 1: + tWidget->addTab(new ProcessWidget(0, *it), (*it)->getIp()); + break; + case 2: + tWidget->addTab(new ProcessWidget(0, *it), (*it)->getLoginName()); + break; + default: tWidget->addTab(new ProcessWidget(0, *it), (*it)->getUserName()); - else if (!(*it)->getConnectionFrame()->getFrame()) - ConsoleLog writeError(QString("The Frame connection from client: "). - append((*it)->getConnectionFrame()->getTaskbarTitle()). - append(QString(" is corrupted. Reconnect the client it again."))); + break; + } } } diff --git a/src/gui/processesDialog.h b/src/gui/processesDialog.h index 9d98136..d2bcae1 100644 --- a/src/gui/processesDialog.h +++ b/src/gui/processesDialog.h @@ -21,7 +21,7 @@ class MainWindow; class ProcessDialog : public QDialog { Q_OBJECT public: - ProcessDialog(QDialog *parent = 0); + ProcessDialog(QDialog *parent = 0, int displayedClientNameEnum = 0); ~ProcessDialog(); diff --git a/src/gui/processesStartDialog.cpp b/src/gui/processesStartDialog.cpp index b4c8c79..f176f7e 100644 --- a/src/gui/processesStartDialog.cpp +++ b/src/gui/processesStartDialog.cpp @@ -19,9 +19,11 @@ #include <src/gui/mainWindow.h> ProcessesStartDialog::ProcessesStartDialog(QWidget *parent) : - QDialog(parent) + QDialog(parent), + procStartUi(new Ui::ProcessesStartDialog) { - textLabel = new QLabel; + procStartUi->setupUi(this); + /*textLabel = new QLabel; textLabel->setText("Process to start:"); messageEdit = new QLineEdit; @@ -36,11 +38,16 @@ ProcessesStartDialog::ProcessesStartDialog(QWidget *parent) : layout->addWidget(textLabel,0,0); layout->addWidget(messageEdit,1,0); - layout->addWidget(cancelButton,2,0); + layout->addWidget(cancelButton,2,1); layout->addWidget(sendButton,2,0); setLayout(layout); - setWindowTitle(tr("PVS start Process")); + setWindowTitle(tr("PVS start Process"));*/ + + connect( procStartUi->sendButton, SIGNAL( clicked()), this, SLOT( send())); + connect( procStartUi->cancelButton, SIGNAL( clicked()), this, SLOT( notSend())); + procStartUi->listOfProcessesButton->hide(); + //connect( procStartUi->listOfProcessesButton, SIGNAL( clicked()), this, SLOT( listProcesses())); } ProcessesStartDialog::~ProcessesStartDialog() @@ -50,26 +57,32 @@ ProcessesStartDialog::~ProcessesStartDialog() void ProcessesStartDialog::send() { - QString procd = messageEdit->text(); - MainWindow::getWindow()->setProcessesDialog(procd); - messageEdit->clear(); - emit accept(); + QString procd = procStartUi->message->text(); + + if (procd.length()>0) + { + QMessageBox::StandardButton start = QMessageBox::question(0, + tr("PVS Start Process"), tr("Do you want to start the process: ") + procd + + tr(" on the selected Clients?"), + QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Ok); + + if (start == QMessageBox::Ok) + { + //write name of process to setProcessesDialog + MainWindow::getWindow()->setProcessesDialog(procd); + } + procStartUi->message->clear(); + emit accept(); + } } -void ProcessesStartDialog::NotSend() +void ProcessesStartDialog::notSend() { - messageEdit->clear(); + procStartUi->message->clear(); emit reject(); } -/*void ProcessesStartDialog::changeEvent(QEvent *e) +void ProcessesStartDialog::listProcesses() { - //QDialog::changeEvent(e); - //switch (e->type()) { - //case QEvent::LanguageChange: - // procstartui->retranslateUi(this); - // break; - //default: - // break; - //} -}*/ + // +} diff --git a/src/gui/processesStartDialog.h b/src/gui/processesStartDialog.h index 61aee4f..856279b 100644 --- a/src/gui/processesStartDialog.h +++ b/src/gui/processesStartDialog.h @@ -3,29 +3,33 @@ #include <QDialog> #include <QtGui> +#include "ui_processesStartDialog.h" +namespace Ui { + class ProcessesStartDialog; +} class MainWindow; - +class QDialog; class ProcessesStartDialog : public QDialog { Q_OBJECT public: ProcessesStartDialog(QWidget *parent = 0); ~ProcessesStartDialog(); -/*protected: - void changeEvent(QEvent *e);*/ - private: - QGridLayout *layout; + Ui::ProcessesStartDialog *procStartUi; + + /*QGridLayout *layout; QLabel *textLabel; QLineEdit *messageEdit; QPushButton *sendButton; - QPushButton *cancelButton; + QPushButton *cancelButton;*/ private slots: void send(); - void NotSend(); + void notSend(); + void listProcesses(); }; #endif // PROCESSESSTARTDIALOG_H diff --git a/src/gui/ui/processWidget.ui b/src/gui/ui/processWidget.ui index 3e7f55e..5ada967 100644 --- a/src/gui/ui/processWidget.ui +++ b/src/gui/ui/processWidget.ui @@ -56,7 +56,7 @@ <bool>true</bool> </property> <property name="selectionMode"> - <enum>QAbstractItemView::SingleSelection</enum> + <enum>QAbstractItemView::ExtendedSelection</enum> </property> <property name="selectionBehavior"> <enum>QAbstractItemView::SelectRows</enum> diff --git a/src/gui/ui/processesStartDialog.ui b/src/gui/ui/processesStartDialog.ui index 5d8c7ee..0f6c60a 100644 --- a/src/gui/ui/processesStartDialog.ui +++ b/src/gui/ui/processesStartDialog.ui @@ -6,8 +6,8 @@ <rect> <x>0</x> <y>0</y> - <width>393</width> - <height>109</height> + <width>418</width> + <height>120</height> </rect> </property> <property name="windowTitle"> @@ -16,14 +16,21 @@ <widget class="QWidget" name="layoutWidget"> <property name="geometry"> <rect> - <x>20</x> - <y>20</y> - <width>351</width> - <height>71</height> + <x>10</x> + <y>10</y> + <width>401</width> + <height>101</height> </rect> </property> <layout class="QVBoxLayout" name="verticalLayout"> <item> + <widget class="QLabel" name="label"> + <property name="text"> + <string>Process to start:</string> + </property> + </widget> + </item> + <item> <widget class="QLineEdit" name="message"/> </item> <item> @@ -32,6 +39,13 @@ <number>5</number> </property> <item> + <widget class="QPushButton" name="listOfProcessesButton"> + <property name="text"> + <string>List of Processes</string> + </property> + </widget> + </item> + <item> <spacer name="horizontalSpacer"> <property name="orientation"> <enum>Qt::Horizontal</enum> @@ -45,16 +59,16 @@ </spacer> </item> <item> - <widget class="QPushButton" name="cancel"> + <widget class="QPushButton" name="cancelButton"> <property name="text"> <string>Cancel</string> </property> </widget> </item> <item> - <widget class="QPushButton" name="send"> + <widget class="QPushButton" name="sendButton"> <property name="text"> - <string>Send</string> + <string>Start</string> </property> </widget> </item> diff --git a/src/pvs.cpp b/src/pvs.cpp index bda16f8..5469eaa 100755 --- a/src/pvs.cpp +++ b/src/pvs.cpp @@ -265,15 +265,18 @@ void PVS::onCommand(PVSMsg cmdMessage) } if (ident.compare("STARTPROCESS") == 0) { + processName = message; QProcess *proc = new QProcess( this ); proc->start(message); //we try to run the process with the name message - _pvsServerConnection->sendMessage(PVSMsg(PVSCOMMAND, "PROCESSES", "START Process "+message+": started")); + connect( proc, SIGNAL( error(QProcess::ProcessError)), this, SLOT( processStartErrorOccured(QProcess::ProcessError))); return; } if (ident.compare("KILLPROCESS") == 0) { + processName = message; QProcess *proc = new QProcess( this ); proc->start("kill "+message); //we try to kill the process with the given ID + connect( proc, SIGNAL( error(QProcess::ProcessError)), this, SLOT( processStopErrorOccured(QProcess::ProcessError))); return; } @@ -929,14 +932,18 @@ void PVS::showProc() { //look at procfs QDir procfs("/proc"); - QStringList proc = procfs.entryList(); + QStringList procList = procfs.entryList(); int uid = getuid(); bool write; - - for (int i=0;i<proc.length();i++) //every directory in /proc is checked + if (procList.length() < 1) + { + _pvsServerConnection->sendMessage(PVSMsg(PVSCOMMAND, "PROCESSES", "SHOW ERROR")); + return; + } + for (int i=0;i<procList.length();i++) //every directory in /proc is checked { write = false; - QString tmp = proc.at(i); + QString tmp = procList.at(i); QString snd = ""; if (!tmp.contains(QRegExp("\\D"))) //we have to check if name is number { @@ -992,3 +999,16 @@ void PVS::showProc() } _pvsServerConnection->sendMessage(PVSMsg(PVSCOMMAND, "PROCESSES", "SHOW finished")); //at the end we send that every process has been sent } + +//tell connectionManager that error occured +void PVS::processStartErrorOccured(QProcess::ProcessError error) +{ + _pvsServerConnection->sendMessage(PVSMsg(PVSCOMMAND, "PROCESSES", "START ERROR "+QString::number(error)+" "+processName)); + processName = ""; +} + +void PVS::processStopErrorOccured(QProcess::ProcessError error) +{ + _pvsServerConnection->sendMessage(PVSMsg(PVSCOMMAND, "PROCESSES", "STOP ERROR "+QString::number(error)+" "+processName)); + processName = ""; +} @@ -171,6 +171,7 @@ private: int _timerLockTest; int _timerLockDelay; + QString processName; // input event handling: unprivileged_handler_chain _inputEventHandlers; @@ -191,6 +192,8 @@ private Q_SLOTS: void outgoingMulticastTransferDelete(qulonglong transferID); void incomingMulticastTransferDelete(qulonglong transferID); void onIncomingMulticastTransferRetry(QString const& sender, qulonglong transferID); + void processStartErrorOccured(QProcess::ProcessError error); + void processStopErrorOccured(QProcess::ProcessError error); private: QSettings _settings; |