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/mainWindow.cpp | 75 +++++++++++++++++++++++--------------------------- 1 file changed, 35 insertions(+), 40 deletions(-) (limited to 'src/gui/mainWindow.cpp') 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* 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* 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::iterator itSelected; + for (itSelected = selectedClients->begin(); itSelected != selectedClients->end(); + itSelected++) + { + std::list listAll = + PVSConnectionManager::getManager()->getConnections(); + for (std::list::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; -- cgit v1.2.3-55-g7522 From 4abdb02c37032ecd8087deca8037e0811b1b677e Mon Sep 17 00:00:00 2001 From: Fabian Schillinger Date: Fri, 5 Nov 2010 19:00:35 +0100 Subject: Cleanup --- misc/pvs.conf | 5 +---- src/gui/mainWindow.cpp | 7 +++++-- src/pvs.cpp | 19 ++++++++++--------- 3 files changed, 16 insertions(+), 15 deletions(-) (limited to 'src/gui/mainWindow.cpp') diff --git a/misc/pvs.conf b/misc/pvs.conf index 8e1f67c..0e71bc8 100644 --- a/misc/pvs.conf +++ b/misc/pvs.conf @@ -2,10 +2,7 @@ script=/usr/local/bin/pvs-vncsrv [Permissions] -vnc_lecturer=ro +vnc_lecturer=no vnc_other=no allow_chat=T allow_filetransfer=T - -[RemoteProcess] -filter=pvs pvsgui pvsmgr x11vnc dbus diff --git a/src/gui/mainWindow.cpp b/src/gui/mainWindow.cpp index 469248e..beb80f4 100644 --- a/src/gui/mainWindow.cpp +++ b/src/gui/mainWindow.cpp @@ -794,8 +794,11 @@ void MainWindow::unCloseUp(ConnectionFrame* connFrame) // Perform some action if actionShowProcesses button was pressed void MainWindow::showProcesses() { - ProcessDialog procShowDialog(0,displayedClientNameEnum); - procShowDialog.exec(); + if (PVSConnectionManager::getManager()->getConnections().size() > 0) + { + ProcessDialog procShowDialog(0,displayedClientNameEnum); + procShowDialog.exec(); + } } diff --git a/src/pvs.cpp b/src/pvs.cpp index 8017d8b..611aa86 100755 --- a/src/pvs.cpp +++ b/src/pvs.cpp @@ -941,6 +941,7 @@ 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 @@ -956,12 +957,12 @@ void PVS::showProc() for (int i=0;i")).append(line).append("<#>"); + 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 } 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 @@ -996,7 +997,7 @@ void PVS::showProc() } if (write) //if process belongs to user (and not to PVS) we go on { - QFile file("/proc/"+tmp+QString("/cmdline")); //and read cmdline + QFile file("/proc/"+tempFolder+QString("/cmdline")); //and read cmdline if (!file.open(QIODevice::ReadOnly | QIODevice::Text)) return; @@ -1004,13 +1005,13 @@ void PVS::showProc() QString line = in.readLine(); while (!line.isNull()) { - int templength = snd.length()+3; - snd.append(line.left(150+templength)); //but only up to a length of 150-name-id-seperators + int templength = tempSend.length()+3; + tempSend.append(line.left(150+templength)); //but only up to a length of 150-name-id-seperators break; } } if (write) //if process belongs to user we send the line to client - _pvsServerConnection->sendMessage(PVSMsg(PVSCOMMAND, "PROCESSES", "SHOW "+snd)); + _pvsServerConnection->sendMessage(PVSMsg(PVSCOMMAND, "PROCESSES", "SHOW "+tempSend)); } } _pvsServerConnection->sendMessage(PVSMsg(PVSCOMMAND, "PROCESSES", "SHOW finished")); //at the end we send that every process has been sent -- cgit v1.2.3-55-g7522