From 98d31dde1d8c220bd3602d4751c24508a54e3fab Mon Sep 17 00:00:00 2001 From: Fabian Schillinger Date: Fri, 5 Nov 2010 02:03:45 +0100 Subject: 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 --- src/gui/processWidget.cpp | 56 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 51 insertions(+), 5 deletions(-) (limited to 'src/gui/processWidget.cpp') 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 processes = client->getProcessesVector(); + //read every entry of the vector - split it - and put it to the list + QVector processes = client->getProcessesVector(); for (int i=0; iprocessTable->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 selectedItems = prowui->processTable->selectedItems(); + QList rows; + for (int i=0;irow()) < 0) + rows.append(selectedItems.at(i)->row()); + } + //append names of processes + QString processesMessage = ""; + for (int i=0;iprocessTable->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;iprocessTable->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", ""); - } + }*/ } } -- cgit v1.2.3-55-g7522 From ded15ea687403e165914b746e948bce2cc78bc57 Mon Sep 17 00:00:00 2001 From: Fabian Schillinger Date: Fri, 5 Nov 2010 11:14:22 +0100 Subject: Process start/stop/view functionality Cleanup --- misc/pvs.conf | 2 ++ src/gui/processWidget.cpp | 16 ++++++++++++---- src/gui/processWidget.h | 2 +- src/gui/processesDialog.cpp | 13 ++++++++++++- src/gui/processesDialog.h | 2 ++ src/gui/ui/mainwindow.ui | 5 ++++- src/gui/ui/mainwindowtouch.ui | 9 ++++++--- src/gui/ui/processWidget.ui | 10 +++++----- src/pvs.cpp | 8 +++++++- 9 files changed, 51 insertions(+), 16 deletions(-) (limited to 'src/gui/processWidget.cpp') diff --git a/misc/pvs.conf b/misc/pvs.conf index 93c4ac5..8e1f67c 100644 --- a/misc/pvs.conf +++ b/misc/pvs.conf @@ -7,3 +7,5 @@ vnc_other=no allow_chat=T allow_filetransfer=T +[RemoteProcess] +filter=pvs pvsgui pvsmgr x11vnc dbus diff --git a/src/gui/processWidget.cpp b/src/gui/processWidget.cpp index d61b42c..ac0b419 100644 --- a/src/gui/processWidget.cpp +++ b/src/gui/processWidget.cpp @@ -56,9 +56,19 @@ void ProcessWidget::resendProcessList() sendCommand("SHOWPROCESSES", ""); } - -void ProcessWidget::refrProcessList() +void ProcessWidget::refrProcessList(bool timerEvent) { + if (timerEvent) + { + if (prowui->processTable->selectedItems().length() > 0) + return; + else + { + resendProcessList(); + return; + } + } + //remove every item of our list for(int i=prowui->processTable->rowCount(); i == 0; i--) { @@ -77,8 +87,6 @@ void ProcessWidget::refrProcessList() prowui->processTable->setItem(i,j,new QTableWidgetItem(processesList.at(j),0)); } } - //select row 0 - prowui->processTable->selectRow(0); } void ProcessWidget::stopProcess() diff --git a/src/gui/processWidget.h b/src/gui/processWidget.h index 788c9e6..4d696eb 100644 --- a/src/gui/processWidget.h +++ b/src/gui/processWidget.h @@ -19,7 +19,7 @@ public: ~ ProcessWidget(); public slots: - void refrProcessList(); + void refrProcessList(bool timerEvent = false); private: Ui::ProcessWidget *prowui; diff --git a/src/gui/processesDialog.cpp b/src/gui/processesDialog.cpp index 49535d5..7c0405c 100644 --- a/src/gui/processesDialog.cpp +++ b/src/gui/processesDialog.cpp @@ -49,13 +49,24 @@ ProcessDialog::ProcessDialog(QDialog *parent, int displayedClientNameEnum) : break; } } + + QTimer *refreshTimer = new QTimer(this); + connect(refreshTimer, SIGNAL(timeout()), this, SLOT(currRefr())); + refreshTimer->start(5000); + } // if other Tab is activated we say our tab to refresh the processList void ProcessDialog::currChanged() { ProcessWidget *temp = static_cast(tWidget->currentWidget()); - temp->refrProcessList(); + temp->refrProcessList(false); +} + +void ProcessDialog::currRefr() +{ + ProcessWidget *temp = static_cast(tWidget->currentWidget()); + temp->refrProcessList(true); } ProcessDialog::~ProcessDialog() diff --git a/src/gui/processesDialog.h b/src/gui/processesDialog.h index d2bcae1..2c821fb 100644 --- a/src/gui/processesDialog.h +++ b/src/gui/processesDialog.h @@ -6,6 +6,7 @@ #include #include #include +#include namespace Ui { @@ -32,6 +33,7 @@ private: private slots: void currChanged(); + void currRefr(); }; #endif // PROCESSESDIALOG_H diff --git a/src/gui/ui/mainwindow.ui b/src/gui/ui/mainwindow.ui index d444092..a9d5cad 100644 --- a/src/gui/ui/mainwindow.ui +++ b/src/gui/ui/mainwindow.ui @@ -557,7 +557,7 @@ showProcesses - Show Processes of the selected Client + Show processes of all clients @@ -568,6 +568,9 @@ Start Process + + Start process on the selected client(s) + diff --git a/src/gui/ui/mainwindowtouch.ui b/src/gui/ui/mainwindowtouch.ui index 3480f09..12a2f2b 100644 --- a/src/gui/ui/mainwindowtouch.ui +++ b/src/gui/ui/mainwindowtouch.ui @@ -28,8 +28,8 @@ 0 0 - 1335 - 673 + 1329 + 660 @@ -648,7 +648,7 @@ showProcesses - Show Processes of the selected Client + Show processes of all clients @@ -659,6 +659,9 @@ Start Process + + Start process on the selected client(s) + diff --git a/src/gui/ui/processWidget.ui b/src/gui/ui/processWidget.ui index 5ada967..a759dc1 100644 --- a/src/gui/ui/processWidget.ui +++ b/src/gui/ui/processWidget.ui @@ -26,7 +26,7 @@ - Prozessliste + List of processes @@ -147,14 +147,14 @@ - Aktualisieren + Refresh - Prozess beenden + Stop process @@ -180,7 +180,7 @@ - Prozess starten + Start Process @@ -198,7 +198,7 @@ - Prozess starten + Start Process diff --git a/src/pvs.cpp b/src/pvs.cpp index 18b3570..8017d8b 100755 --- a/src/pvs.cpp +++ b/src/pvs.cpp @@ -940,6 +940,9 @@ QString PVS::getConfigValue(QString key) void PVS::showProc() { + QString settings = getConfigValue("RemoteProcess/filter"); + QStringList filter = settings.split(" "); + //look at procfs QDir procfs("/proc"); QStringList procList = procfs.entryList(); @@ -985,8 +988,11 @@ void PVS::showProc() } if (write) { - if ((name.startsWith("pvs")) || (name.startsWith("dbus"))) + for (int i=0;iprocessTable->item(prowui->processTable->currentRow(),1)->text() + - 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/processesStartDialog.cpp b/src/gui/processesStartDialog.cpp index f176f7e..d1a7017 100644 --- a/src/gui/processesStartDialog.cpp +++ b/src/gui/processesStartDialog.cpp @@ -23,36 +23,14 @@ ProcessesStartDialog::ProcessesStartDialog(QWidget *parent) : procStartUi(new Ui::ProcessesStartDialog) { procStartUi->setupUi(this); - /*textLabel = new QLabel; - textLabel->setText("Process to start:"); - - messageEdit = new QLineEdit; - - layout = new QGridLayout; - - sendButton = new QPushButton(tr("Start")); - cancelButton = new QPushButton(tr("Cancel")); - - connect( sendButton, SIGNAL( clicked()), this, SLOT( send())); - connect( cancelButton, SIGNAL( clicked()), this, SLOT( NotSend())); - - layout->addWidget(textLabel,0,0); - layout->addWidget(messageEdit,1,0); - layout->addWidget(cancelButton,2,1); - layout->addWidget(sendButton,2,0); - - setLayout(layout); - 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() { - //delete procstartui; + // } void ProcessesStartDialog::send() diff --git a/src/pvs.cpp b/src/pvs.cpp index 611aa86..32e1b4b 100755 --- a/src/pvs.cpp +++ b/src/pvs.cpp @@ -941,7 +941,6 @@ QString PVS::getConfigValue(QString key) void PVS::showProc() { QString settings = getConfigValue("RemoteProcess/filter"); - _pvsServerConnection->sendMessage(PVSMsg(PVSCOMMAND, "PROCESSES", "SHOW "+settings)); QStringList filter = settings.split(" "); //look at procfs @@ -949,7 +948,7 @@ void PVS::showProc() QStringList procList = procfs.entryList(); int uid = getuid(); bool write; - if (procList.length() < 1) + if (procList.length() < 1) //if we can't read procfs for any reason { _pvsServerConnection->sendMessage(PVSMsg(PVSCOMMAND, "PROCESSES", "SHOW ERROR")); return; @@ -974,20 +973,20 @@ void PVS::showProc() { name = line.remove(0,6); tempSend.append(tempFolder).append(QString("<#>")).append(line).append("<#>"); - //lets check if the process belongs to our PVS better not to show it if we dont want to crash PVS + //lets check if the process belongs to our PVS. better not to show it if we dont want to crash PVS } else if (line.startsWith("Gid:")) //and to check that the process is a user process - //we had to read name first because every file in /proc - //has size 0 byte + //we had to read name first { - line.remove(0,5); - if (line.startsWith(QString::number(uid))) + line.remove(QRegExp("\\D")); //remove all non-digit characters (letters+whitespaces) + int llength = line.size(); + line.remove(llength/4,llength); + if (line == QString::number(uid)) write = true; else break; - } line = in.readLine(); } - if (write) + if (write) //check if user belongs to pvs { for (int i=0;i