summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorSebastien Braun2010-11-10 01:47:26 +0100
committerSebastien Braun2010-11-10 01:47:26 +0100
commitb2c87269579df6cdd10e4419e0817d6d829a302e (patch)
tree70d93ceb460dc34b851fe928eedd71a8fffe1f6a /src
parentAdd Makefile to generate PDF from DIA figures and call pdflatex and (diff)
parentMerge branch 'master' of openslx.org:pvs (diff)
downloadpvs-b2c87269579df6cdd10e4419e0817d6d829a302e.tar.gz
pvs-b2c87269579df6cdd10e4419e0817d6d829a302e.tar.xz
pvs-b2c87269579df6cdd10e4419e0817d6d829a302e.zip
Merge branch 'master' of ssh://git.openslx.org/pvs
Diffstat (limited to 'src')
-rw-r--r--src/core/pvsConnectionManager.cpp76
-rw-r--r--src/gui/mainWindow.cpp74
-rw-r--r--src/gui/mainWindow.h11
-rw-r--r--src/gui/processWidget.cpp72
-rw-r--r--src/gui/processWidget.h5
-rw-r--r--src/gui/processesDialog.cpp39
-rw-r--r--src/gui/processesDialog.h4
-rw-r--r--src/gui/processesStartDialog.cpp142
-rw-r--r--src/gui/processesStartDialog.h21
-rw-r--r--src/gui/ui/mainwindow.ui5
-rw-r--r--src/gui/ui/mainwindowtouch.ui9
-rw-r--r--src/gui/ui/processWidget.ui12
-rw-r--r--src/gui/ui/processesDialog.ui2
-rw-r--r--src/gui/ui/processesStartDialog.ui193
-rwxr-xr-xsrc/pvs.cpp70
-rwxr-xr-xsrc/pvs.h3
16 files changed, 537 insertions, 201 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 1376851..beb80f4 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
@@ -791,57 +791,47 @@ void MainWindow::unCloseUp(ConnectionFrame* connFrame)
conWin->setCloseupFrame(NULL);
}
-/* 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)
+ if (PVSConnectionManager::getManager()->getConnections().size() > 0)
{
- ProcessDialog procDialog;
- procDialog.exec();
-
+ ProcessDialog procShowDialog(0,displayedClientNameEnum);
+ procShowDialog.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);
- }
-
}
-/* 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
{
@@ -901,6 +891,7 @@ void MainWindow::createProfile()
void MainWindow::showusername()
{
+ displayedClientNameEnum = 2;
MainWindow::getConnectionList()->setColumnHidden(2, false);
MainWindow::getConnectionList()->setColumnHidden(0, true);
MainWindow::getConnectionList()->setColumnHidden(1, true);
@@ -908,6 +899,7 @@ void MainWindow::showusername()
void MainWindow::showname()
{
+ displayedClientNameEnum = 0;
MainWindow::getConnectionList()->setColumnHidden(0, false);
MainWindow::getConnectionList()->setColumnHidden(1, true);
MainWindow::getConnectionList()->setColumnHidden(2, true);
@@ -915,6 +907,7 @@ void MainWindow::showname()
void MainWindow::showip()
{
+ displayedClientNameEnum = 1;
MainWindow::getConnectionList()->setColumnHidden(1, false);
MainWindow::getConnectionList()->setColumnHidden(2, true);
MainWindow::getConnectionList()->setColumnHidden(0, true);
@@ -1314,6 +1307,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 58787ed..272d057 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;
@@ -188,6 +188,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..38dd2ae 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,33 @@ void ProcessWidget::startProcess()
prowui->processLineEdit->clear();
}
-void ProcessWidget::refrProcessList()
+void ProcessWidget::resendProcessList()
{
+ sendCommand("SHOWPROCESSES", "");
+}
+
+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--)
{
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,22 +87,47 @@ void ProcessWidget::refrProcessList()
prowui->processTable->setItem(i,j,new QTableWidgetItem(processesList.at(j),0));
}
}
- prowui->processTable->selectRow(0);
}
void ProcessWidget::stopProcess()
{
if (prowui->processTable->rowCount() > 0)
{
- 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("' ?"),
- QMessageBox::Ok | QMessageBox::Cancel, QMessageBox::Ok);
- if (start == QMessageBox::Ok)
- {
- sendCommand("KILLPROCESS", prowui->processTable->item(prowui->processTable->currentRow(),0)->text());
- sendCommand("SHOWPROCESSES", "");
- }
+ //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", "");
}
}
diff --git a/src/gui/processWidget.h b/src/gui/processWidget.h
index 7e7eb72..4d696eb 100644
--- a/src/gui/processWidget.h
+++ b/src/gui/processWidget.h
@@ -17,9 +17,9 @@ class ProcessWidget: public QWidget
public:
ProcessWidget(QWidget *parent, PVSClient *client);
~ ProcessWidget();
- QAbstractItemModel *model;
+
public slots:
- void refrProcessList();
+ void refrProcessList(bool timerEvent = false);
private:
Ui::ProcessWidget *prowui;
@@ -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..7c0405c 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,23 +35,38 @@ 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;
+ }
}
+
+ 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<ProcessWidget*>(tWidget->currentWidget());
- temp->refrProcessList();
+ temp->refrProcessList(false);
+}
+
+void ProcessDialog::currRefr()
+{
+ ProcessWidget *temp = static_cast<ProcessWidget*>(tWidget->currentWidget());
+ temp->refrProcessList(true);
}
ProcessDialog::~ProcessDialog()
diff --git a/src/gui/processesDialog.h b/src/gui/processesDialog.h
index 9d98136..2c821fb 100644
--- a/src/gui/processesDialog.h
+++ b/src/gui/processesDialog.h
@@ -6,6 +6,7 @@
#include <src/gui/processWidget.h>
#include <src/gui/mainWindow.h>
#include <list>
+#include <QTimer>
namespace Ui {
@@ -21,7 +22,7 @@ class MainWindow;
class ProcessDialog : public QDialog {
Q_OBJECT
public:
- ProcessDialog(QDialog *parent = 0);
+ ProcessDialog(QDialog *parent = 0, int displayedClientNameEnum = 0);
~ProcessDialog();
@@ -32,6 +33,7 @@ private:
private slots:
void currChanged();
+ void currRefr();
};
#endif // PROCESSESDIALOG_H
diff --git a/src/gui/processesStartDialog.cpp b/src/gui/processesStartDialog.cpp
index b4c8c79..e0a6286 100644
--- a/src/gui/processesStartDialog.cpp
+++ b/src/gui/processesStartDialog.cpp
@@ -19,57 +19,127 @@
#include <src/gui/mainWindow.h>
ProcessesStartDialog::ProcessesStartDialog(QWidget *parent) :
- QDialog(parent)
+ QDialog(parent),
+ procStartUi(new Ui::ProcessesStartDialog)
{
- textLabel = new QLabel;
- textLabel->setText("Process to start:");
+ procStartUi->setupUi(this);
+ connect( procStartUi->sendButton, SIGNAL( clicked()), this, SLOT( send()));
+ connect( procStartUi->cancelButton, SIGNAL( clicked()), this, SLOT( notSend()));
+ connect( procStartUi->saveButton, SIGNAL( clicked()), this, SLOT ( save()));
- messageEdit = new QLineEdit;
+ //if we click or double click one of our items we put it in our message
+ connect( procStartUi->processesList, SIGNAL( cellDoubleClicked(int,int)), this, SLOT ( itemClicked(int,int)));
+ connect( procStartUi->processesList, SIGNAL( cellClicked(int,int)), this, SLOT ( itemClicked(int,int)));
- 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,0);
- layout->addWidget(sendButton,2,0);
-
- setLayout(layout);
- setWindowTitle(tr("PVS start Process"));
+ listProcesses();
}
ProcessesStartDialog::~ProcessesStartDialog()
{
- //delete procstartui;
+ //
}
void ProcessesStartDialog::send()
{
- QString procd = messageEdit->text();
- MainWindow::getWindow()->setProcessesDialog(procd);
- messageEdit->clear();
- emit accept();
+ QString procd = procStartUi->message->text();
+ save(); //save (if we made changes to our list)
+ 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;
- //}
-}*/
+ /*settings.beginWriteArray("RemoteProcessesList");
+ settings.setArrayIndex(0);
+ settings.setValue("command", "oowriter");
+ settings.setValue("description", "Open Office Writer");
+ settings.setArrayIndex(1);
+ settings.setValue("command", "oocalc");
+ settings.setValue("description", "Open Office Calc");
+ settings.endArray();*/
+
+ //read from settings
+ int size = settings.beginReadArray("RemoteProcessesList");
+ for (int i = 0; i < size; ++i)
+ {
+ settings.setArrayIndex(i);
+ procStartUi->processesList->setRowCount(i+1);
+ procStartUi->processesList->setItem(i, 0, new QTableWidgetItem(settings.value("command").toString(),0));
+ procStartUi->processesList->setItem(i, 1, new QTableWidgetItem(settings.value("description").toString(),0));
+ }
+ settings.endArray();
+
+ //add empty items to our List
+ QString empty = " ";
+ procStartUi->processesList->setRowCount(procStartUi->processesList->rowCount()+1);
+ procStartUi->processesList->setItem(procStartUi->processesList->rowCount()-1, 0, new QTableWidgetItem(empty,0));
+ procStartUi->processesList->setItem(procStartUi->processesList->rowCount()-1, 1, new QTableWidgetItem(empty,0));
+}
+
+void ProcessesStartDialog::save()
+{
+ //if we delete items from our list we increment our decrement - to decrement our arrayindex
+ int decrement = 0;
+
+ // if both our last elements are empty dont read them
+ // we need this if we have added new elements
+ if ((procStartUi->processesList->item(procStartUi->processesList->rowCount()-1, 0) != 0) &&
+ (procStartUi->processesList->item(procStartUi->processesList->rowCount()-1, 1) != 0))
+ {
+ settings.beginWriteArray("RemoteProcessesList");
+ for (int i = 0; i < procStartUi->processesList->rowCount(); ++i)
+ {
+ //if elements are only whitespaces we ignore them
+ if ((procStartUi->processesList->item(i, 0)->text().remove(QRegExp("\\s")) != "") &&
+ (procStartUi->processesList->item(i, 1)->text().remove(QRegExp("\\s")) != ""))
+ {
+ settings.setArrayIndex(i-decrement);
+ settings.setValue("command", procStartUi->processesList->item(i, 0)->text());
+ settings.setValue("description", procStartUi->processesList->item(i, 1)->text());
+ } else decrement++; //and increment our decrement
+ }
+ settings.endArray();
+ }
+ else
+ {
+ settings.beginWriteArray("RemoteProcessesList");
+ for (int i = 0; i < procStartUi->processesList->rowCount()-1; ++i)
+ {
+ if ((procStartUi->processesList->item(i, 0)->text().remove(QRegExp("\\s")) != "") &&
+ (procStartUi->processesList->item(i, 1)->text().remove(QRegExp("\\s")) != ""))
+ {
+ settings.setArrayIndex(i-decrement);
+ settings.setValue("command", procStartUi->processesList->item(i, 0)->text());
+ settings.setValue("description", procStartUi->processesList->item(i, 1)->text());
+ } else decrement++;
+ }
+ settings.endArray();
+ }
+ listProcesses();
+}
+
+void ProcessesStartDialog::itemClicked(int row, int column)
+{
+ //if last item exists we put it in our message
+ if (procStartUi->processesList->item(row, 0) != 0)
+ procStartUi->message->setText(procStartUi->processesList->item(row, 0)->text());
+}
diff --git a/src/gui/processesStartDialog.h b/src/gui/processesStartDialog.h
index 61aee4f..358a356 100644
--- a/src/gui/processesStartDialog.h
+++ b/src/gui/processesStartDialog.h
@@ -3,29 +3,30 @@
#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;
- QLabel *textLabel;
- QLineEdit *messageEdit;
- QPushButton *sendButton;
- QPushButton *cancelButton;
+ Ui::ProcessesStartDialog *procStartUi;
+ QSettings settings;
private slots:
void send();
- void NotSend();
+ void notSend();
+ void listProcesses();
+ void save();
+ void itemClicked(int row, int column);
};
#endif // PROCESSESSTARTDIALOG_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 @@
<string>showProcesses</string>
</property>
<property name="toolTip">
- <string>Show Processes of the selected Client</string>
+ <string>Show processes of all clients</string>
</property>
</action>
<action name="actionStartProcess">
@@ -568,6 +568,9 @@
<property name="text">
<string>Start Process</string>
</property>
+ <property name="toolTip">
+ <string>Start process on the selected client(s)</string>
+ </property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
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 @@
<rect>
<x>0</x>
<y>0</y>
- <width>1335</width>
- <height>673</height>
+ <width>1329</width>
+ <height>660</height>
</rect>
</property>
<layout class="QGridLayout" name="gridLayout_3">
@@ -648,7 +648,7 @@
<string>showProcesses</string>
</property>
<property name="toolTip">
- <string>Show Processes of the selected Client</string>
+ <string>Show processes of all clients</string>
</property>
</action>
<action name="actionStartProcess">
@@ -659,6 +659,9 @@
<property name="text">
<string>Start Process</string>
</property>
+ <property name="toolTip">
+ <string>Start process on the selected client(s)</string>
+ </property>
</action>
</widget>
<layoutdefault spacing="6" margin="11"/>
diff --git a/src/gui/ui/processWidget.ui b/src/gui/ui/processWidget.ui
index 3e7f55e..a759dc1 100644
--- a/src/gui/ui/processWidget.ui
+++ b/src/gui/ui/processWidget.ui
@@ -26,7 +26,7 @@
<item>
<widget class="QGroupBox" name="groupBox_2">
<property name="title">
- <string>Prozessliste</string>
+ <string>List of processes</string>
</property>
<widget class="QWidget" name="verticalLayoutWidget">
<property name="geometry">
@@ -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>
@@ -147,14 +147,14 @@
<item>
<widget class="QPushButton" name="refreshButton">
<property name="text">
- <string>Aktualisieren</string>
+ <string>Refresh</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="stopButton">
<property name="text">
- <string>Prozess beenden</string>
+ <string>Stop process</string>
</property>
</widget>
</item>
@@ -180,7 +180,7 @@
</size>
</property>
<property name="title">
- <string>Prozess starten</string>
+ <string>Start Process</string>
</property>
<widget class="QWidget" name="horizontalLayoutWidget">
<property name="geometry">
@@ -198,7 +198,7 @@
<item>
<widget class="QPushButton" name="startButton">
<property name="text">
- <string>Prozess starten</string>
+ <string>Start Process</string>
</property>
</widget>
</item>
diff --git a/src/gui/ui/processesDialog.ui b/src/gui/ui/processesDialog.ui
index 4ac4859..14d2403 100644
--- a/src/gui/ui/processesDialog.ui
+++ b/src/gui/ui/processesDialog.ui
@@ -11,7 +11,7 @@
</rect>
</property>
<property name="windowTitle">
- <string>Prozesse</string>
+ <string>Processes</string>
</property>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="geometry">
diff --git a/src/gui/ui/processesStartDialog.ui b/src/gui/ui/processesStartDialog.ui
index 5d8c7ee..2003c57 100644
--- a/src/gui/ui/processesStartDialog.ui
+++ b/src/gui/ui/processesStartDialog.ui
@@ -6,58 +6,191 @@
<rect>
<x>0</x>
<y>0</y>
- <width>393</width>
- <height>109</height>
+ <width>524</width>
+ <height>309</height>
</rect>
</property>
<property name="windowTitle">
<string>Start Process</string>
</property>
- <widget class="QWidget" name="layoutWidget">
+ <widget class="QWidget" name="verticalLayoutWidget_3">
<property name="geometry">
<rect>
- <x>20</x>
- <y>20</y>
- <width>351</width>
- <height>71</height>
+ <x>10</x>
+ <y>10</y>
+ <width>503</width>
+ <height>291</height>
</rect>
</property>
- <layout class="QVBoxLayout" name="verticalLayout">
+ <layout class="QVBoxLayout" name="outerVerticalLayout">
<item>
- <widget class="QLineEdit" name="message"/>
- </item>
- <item>
- <layout class="QHBoxLayout" name="horizontalLayout">
- <property name="spacing">
- <number>5</number>
- </property>
+ <layout class="QVBoxLayout" name="upperVerticalLayout">
<item>
- <spacer name="horizontalSpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>108</width>
- <height>20</height>
- </size>
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Either use a command from this list or type in the process in the lower field.</string>
</property>
- </spacer>
+ </widget>
</item>
<item>
- <widget class="QPushButton" name="cancel">
- <property name="text">
- <string>Cancel</string>
+ <widget class="QTableWidget" name="processesList">
+ <property name="verticalScrollBarPolicy">
+ <enum>Qt::ScrollBarAsNeeded</enum>
+ </property>
+ <property name="horizontalScrollBarPolicy">
+ <enum>Qt::ScrollBarAlwaysOff</enum>
+ </property>
+ <property name="editTriggers">
+ <set>QAbstractItemView::DoubleClicked|QAbstractItemView::SelectedClicked</set>
+ </property>
+ <property name="alternatingRowColors">
+ <bool>true</bool>
+ </property>
+ <property name="selectionMode">
+ <enum>QAbstractItemView::SingleSelection</enum>
+ </property>
+ <property name="selectionBehavior">
+ <enum>QAbstractItemView::SelectRows</enum>
+ </property>
+ <property name="gridStyle">
+ <enum>Qt::DotLine</enum>
+ </property>
+ <property name="sortingEnabled">
+ <bool>false</bool>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
</property>
+ <property name="cornerButtonEnabled">
+ <bool>false</bool>
+ </property>
+ <attribute name="horizontalHeaderVisible">
+ <bool>true</bool>
+ </attribute>
+ <attribute name="horizontalHeaderCascadingSectionResizes">
+ <bool>false</bool>
+ </attribute>
+ <attribute name="horizontalHeaderDefaultSectionSize">
+ <number>200</number>
+ </attribute>
+ <attribute name="horizontalHeaderHighlightSections">
+ <bool>false</bool>
+ </attribute>
+ <attribute name="horizontalHeaderStretchLastSection">
+ <bool>true</bool>
+ </attribute>
+ <attribute name="verticalHeaderVisible">
+ <bool>false</bool>
+ </attribute>
+ <attribute name="verticalHeaderVisible">
+ <bool>false</bool>
+ </attribute>
+ <attribute name="horizontalHeaderStretchLastSection">
+ <bool>true</bool>
+ </attribute>
+ <attribute name="horizontalHeaderCascadingSectionResizes">
+ <bool>false</bool>
+ </attribute>
+ <attribute name="horizontalHeaderVisible">
+ <bool>true</bool>
+ </attribute>
+ <attribute name="horizontalHeaderHighlightSections">
+ <bool>false</bool>
+ </attribute>
+ <attribute name="horizontalHeaderDefaultSectionSize">
+ <number>200</number>
+ </attribute>
+ <column>
+ <property name="text">
+ <string>Command</string>
+ </property>
+ </column>
+ <column>
+ <property name="text">
+ <string>Description</string>
+ </property>
+ </column>
</widget>
</item>
<item>
- <widget class="QPushButton" name="send">
+ <layout class="QHBoxLayout" name="horizontalLayout_3">
+ <item>
+ <spacer name="horizontalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="saveButton">
+ <property name="text">
+ <string>Save</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="Line" name="line">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QVBoxLayout" name="lowerVerticalLayout">
+ <item>
+ <widget class="QLabel" name="label">
<property name="text">
- <string>Send</string>
+ <string>Process to start:</string>
</property>
</widget>
</item>
+ <item>
+ <widget class="QLineEdit" name="message"/>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
+ <property name="spacing">
+ <number>5</number>
+ </property>
+ <item>
+ <spacer name="horizontalSpacer">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>108</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item>
+ <widget class="QPushButton" name="cancelButton">
+ <property name="text">
+ <string>Cancel</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPushButton" name="sendButton">
+ <property name="text">
+ <string>Start</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
</layout>
</item>
</layout>
diff --git a/src/pvs.cpp b/src/pvs.cpp
index 755eea5..843a725 100755
--- a/src/pvs.cpp
+++ b/src/pvs.cpp
@@ -268,15 +268,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;
}
@@ -937,21 +940,28 @@ QString PVS::getConfigValue(QString key)
void PVS::showProc()
{
+ QString settings = getConfigValue("RemoteProcess/filter");
+ QStringList filter = settings.split(" ");
+
//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) //if we can't read procfs for any reason
+ {
+ _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 snd = "";
- if (!tmp.contains(QRegExp("\\D"))) //we have to check if name is number
+ QString tempFolder = procList.at(i);
+ QString tempSend = "";
+ if (!tempFolder.contains(QRegExp("\\D"))) //we have to check if name is number
{
QString name = "";
- QFile file("/proc/"+tmp+QString("/status")); //read status file
+ QFile file("/proc/"+tempFolder+QString("/status")); //read status file
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
return;
@@ -962,28 +972,31 @@ void PVS::showProc()
if (line.startsWith("Name:")) //to get the name of our process
{
name = line.remove(0,6);
- snd.append(tmp).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
- //has size 0 byte
+ 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("Uid:")) //and to check that the process is a user process
+ //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
{
- if ((name.startsWith("pvs")) || (name.startsWith("dbus")))
+ for (int i=0;i<filter.size();i++)
+ {
+ if (name == (filter.at(i)))
write = false;
+ }
}
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;
@@ -991,14 +1004,27 @@ 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
}
+
+//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 = "";
+}
diff --git a/src/pvs.h b/src/pvs.h
index db87b8e..e3ff329 100755
--- a/src/pvs.h
+++ b/src/pvs.h
@@ -171,6 +171,7 @@ private:
int _timerLockTest;
int _timerLockDelay;
+ QString processName;
// input event handling:
InputEventHandlerChain _inputEventHandlers;
@@ -192,6 +193,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;