Reformat Client

remotes/origin/HEAD
markuspg 7 years ago
parent 385a42dedf
commit e533ede28b

@ -1,5 +1,5 @@
/* /*
* Copyright 2014-2016 Markus Prasser * Copyright 2014-2018 Markus Prasser, Tobias Weiss
* *
* This file is part of Labcontrol. * This file is part of Labcontrol.
* *
@ -17,53 +17,52 @@
* along with Labcontrol. If not, see <http://www.gnu.org/licenses/>. * along with Labcontrol. If not, see <http://www.gnu.org/licenses/>.
*/ */
#include <memory> #include "clientpinger.h"
#include <QDebug>
#include "client.h"
#include "settings.h"
#include "lablib.h" #include "lablib.h"
extern std::unique_ptr< lc::Settings > settings; #include <memory>
extern std::unique_ptr< lc::Lablib > lablib;
extern std::unique_ptr<lc::Settings> settings;
lc::Client::Client( const QString &argIP, const QString &argMAC, const QString &argName, extern std::unique_ptr<lc::Lablib> lablib;
unsigned short int argXPosition, unsigned short int argYPosition,
const QString &argPingCmd ): lc::Client::Client(const QString &argIP, const QString &argMAC, const QString &argName,
ip{ argIP }, const unsigned short int argXPosition,
mac{ argMAC }, const unsigned short int argYPosition,
name{ argName }, const QString &argPingCmd):
xPosition{ argXPosition }, ip{argIP},
yPosition{ argYPosition }, mac{argMAC},
protectedCycles{ 0 } name{argName},
xPosition{argXPosition},
yPosition{argYPosition},
protectedCycles{0}
{ {
qRegisterMetaType< state_t >( "STATE" ); qRegisterMetaType<state_t>("state_t");
if ( !argPingCmd.isEmpty() ) { if (!argPingCmd.isEmpty()) {
pinger = new ClientPinger{ ip, argPingCmd }; pinger = new ClientPinger{ip, argPingCmd};
pinger->moveToThread( &pingerThread ); pinger->moveToThread(&pingerThread);
connect( &pingerThread, &QThread::finished, connect(&pingerThread, &QThread::finished,
pinger, &QObject::deleteLater ); pinger, &QObject::deleteLater);
connect( this, &Client::PingWanted, connect(this, &Client::PingWanted,
pinger, &ClientPinger::doPing ); pinger, &ClientPinger::doPing);
connect( pinger, &ClientPinger::PingFinished, connect(pinger, &ClientPinger::PingFinished,
this, &Client::GotStatusChanged ); this, &Client::GotStatusChanged);
pingerThread.start(); pingerThread.start();
pingTimer = new QTimer{ this }; pingTimer = new QTimer{this};
connect( pingTimer, &QTimer::timeout, connect(pingTimer, &QTimer::timeout,
this, &Client::RequestAPing ) ; this, &Client::RequestAPing) ;
pingTimer->start( 3000 ); pingTimer->start(3000);
} }
qDebug() << "Created client" << name << "with MAC" << mac << "and IP" << ip qDebug() << "Created client" << name << "with MAC" << mac << "and IP" << ip
<< "at position" << QString{ QString::number( xPosition ) + "x" << "at position" << QString{QString::number(xPosition) + "x"
+ QString::number( yPosition ) }; + QString::number(yPosition)};
} }
lc::Client::~Client() { lc::Client::~Client()
if ( pingTimer ) { {
if (pingTimer) {
pingTimer->stop(); pingTimer->stop();
} }
delete pingTimer; delete pingTimer;
@ -71,274 +70,277 @@ lc::Client::~Client() {
pingerThread.wait(); pingerThread.wait();
} }
void lc::Client::BeamFile( const QString &argFileToBeam, const QString * const argPublickeyPathUser, const QString * const argUserNameOnClients ) { void lc::Client::BeamFile(const QString &argFileToBeam,
if ( state < state_t::RESPONDING ) { const QString *const argPublickeyPathUser,
const QString *const argUserNameOnClients)
{
if (state < state_t::RESPONDING) {
return; return;
} }
QStringList arguments; const QStringList arguments{"-2", "-i", *argPublickeyPathUser, "-l",
arguments << "-2" << "-i" << *argPublickeyPathUser << "-l" << "32768" << "-r" "32768", "-r", argFileToBeam,
<< argFileToBeam << QString{ *argUserNameOnClients + "@" + ip + ":media4ztree" }; QString{*argUserNameOnClients + "@" + ip + ":media4ztree"}};
// Start the process // Start the process
QProcess beamFileProcess; QProcess beamFileProcess;
QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); beamFileProcess.setProcessEnvironment(QProcessEnvironment::systemEnvironment());
beamFileProcess.setProcessEnvironment( env ); beamFileProcess.startDetached(settings->scpCmd, arguments);
beamFileProcess.startDetached( settings->scpCmd, arguments );
qDebug() << settings->scpCmd << arguments.join( " " ); qDebug() << settings->scpCmd << arguments.join(" ");
} }
void lc::Client::Boot() { void lc::Client::Boot()
QStringList arguments{ QStringList{} << "-i" << settings->netwBrdAddr << mac }; {
const QStringList arguments{"-i", settings->netwBrdAddr, mac};
// Start the process // Start the process
QProcess wakeonlanProcess; QProcess wakeonlanProcess;
QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); wakeonlanProcess.setProcessEnvironment(QProcessEnvironment::systemEnvironment());
wakeonlanProcess.setProcessEnvironment( env ); wakeonlanProcess.startDetached(settings->wakeonlanCmd, arguments);
wakeonlanProcess.startDetached( settings->wakeonlanCmd, arguments );
// Output message via the debug messages tab // Output message via the debug messages tab
qDebug() << settings->wakeonlanCmd << arguments.join( " " ); qDebug() << settings->wakeonlanCmd << arguments.join(" ");
pingTimer->start( 3000 ); pingTimer->start(3000);
protectedCycles = 7; protectedCycles = 7;
GotStatusChanged( state_t::BOOTING ); GotStatusChanged(state_t::BOOTING);
} }
void lc::Client::GotStatusChanged( state_t argState ) { void lc::Client::GotStatusChanged(state_t argState)
if ( ( protectedCycles > 0 ) && ( state == state_t::BOOTING ) && ( argState != state_t::RESPONDING ) ) { {
if ((protectedCycles > 0) && (state == state_t::BOOTING)
&& (argState != state_t::RESPONDING)) {
return; return;
} }
if ( ( protectedCycles > 0 ) && ( state == state_t::SHUTTING_DOWN ) && argState != state_t::NOT_RESPONDING ) { if ((protectedCycles > 0) && (state == state_t::SHUTTING_DOWN)
&& argState != state_t::NOT_RESPONDING) {
return; return;
} }
state = argState; state = argState;
qDebug() << name << "status changed to:" << static_cast< unsigned short int >( argState ); qDebug() << name << "status changed to:"
<< static_cast<unsigned short int>(argState);
} }
void lc::Client::KillZLeaf() { void lc::Client::KillZLeaf()
QStringList arguments; {
arguments << "-i" << settings->pkeyPathUser const QStringList arguments{"-i", settings->pkeyPathUser,
<< QString{ settings->userNameOnClients + "@" + ip } QString{settings->userNameOnClients + "@" + ip},
<< settings->killallCmd << "-I" << "-q" << "zleaf.exe"; settings->killallCmd, "-I", "-q", "zleaf.exe"};
// Start the process // Start the process
QProcess killZLeafProcess; QProcess killZLeafProcess;
QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); killZLeafProcess.setProcessEnvironment(QProcessEnvironment::systemEnvironment());
killZLeafProcess.setProcessEnvironment( env ); killZLeafProcess.startDetached(settings->sshCmd, arguments);
killZLeafProcess.startDetached( settings->sshCmd, arguments );
// Output message via the debug messages tab // Output message via the debug messages tab
qDebug() << settings->sshCmd << arguments.join( " " ); qDebug() << settings->sshCmd << arguments.join(" ");
// Restart the ping_timer, because it is stopped when a zLeaf is started // Restart the ping_timer, because it is stopped when a zLeaf is started
pingTimer->start( 3000 ); pingTimer->start(3000);
} }
void lc::Client::OpenFilesystem( const QString * const argUserToBeUsed ) { void lc::Client::OpenFilesystem(const QString *const argUserToBeUsed)
if ( state < state_t::RESPONDING ) { {
if (state < state_t::RESPONDING) {
return; return;
} }
QStringList arguments = QStringList{} << QString{ "sftp://" + *argUserToBeUsed + "@" + ip }; const QStringList arguments{QString{ "sftp://" + *argUserToBeUsed + "@" + ip }};
QProcess openFilesystemProcess; QProcess openFilesystemProcess;
QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); openFilesystemProcess.setProcessEnvironment(QProcessEnvironment::systemEnvironment());
openFilesystemProcess.setProcessEnvironment( env ); openFilesystemProcess.startDetached(settings->fileMngr, arguments);
openFilesystemProcess.startDetached( settings->fileMngr, arguments ); qDebug() << settings->fileMngr << arguments.join(" ");
qDebug() << settings->fileMngr << arguments.join( " " );
} }
void lc::Client::OpenTerminal( const QString &argCommand, const bool &argOpenAsRoot ) { void lc::Client::OpenTerminal(const QString &argCommand,
if ( !settings->termEmulCmd.isEmpty() ) { const bool argOpenAsRoot)
if ( state < state_t::RESPONDING ) { {
if (!settings->termEmulCmd.isEmpty()) {
if (state < state_t::RESPONDING) {
return; return;
} }
QStringList *arguments = nullptr; QStringList arguments;
arguments = new QStringList; if (!argOpenAsRoot) {
if ( !argOpenAsRoot ) { arguments << "-e"
*arguments << "-e" << QString{settings->sshCmd + " -i " + settings->pkeyPathUser + " "
<< QString{ settings->sshCmd + " -i " + settings->pkeyPathUser + " " + settings->userNameOnClients + "@" + ip};
+ settings->userNameOnClients + "@" + ip };
} else { } else {
*arguments << "-e" << arguments << "-e" <<
QString{ settings->sshCmd + " -i " + settings->pkeyPathRoot QString{settings->sshCmd + " -i " + settings->pkeyPathRoot
+ " " + "root@" + ip}; + " " + "root@" + ip};
} }
if ( !argCommand.isEmpty() ) { if (!argCommand.isEmpty()) {
arguments->last().append( " '" + argCommand + "'" ); arguments.last().append(" '" + argCommand + "'");
} }
QProcess openTerminalProcess; QProcess openTerminalProcess;
QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); openTerminalProcess.setProcessEnvironment(QProcessEnvironment::systemEnvironment());
openTerminalProcess.setProcessEnvironment( env ); openTerminalProcess.startDetached(settings->termEmulCmd, arguments);
openTerminalProcess.startDetached( settings->termEmulCmd, *arguments ); qDebug() << settings->termEmulCmd << arguments.join(" ");
qDebug() << settings->termEmulCmd << arguments->join( " " );
delete arguments;
} }
} }
void lc::Client::RequestAPing() { void lc::Client::RequestAPing()
if ( protectedCycles > 0 ) { {
if (protectedCycles > 0) {
--protectedCycles; --protectedCycles;
} }
emit PingWanted(); emit PingWanted();
} }
void lc::Client::SetStateToZLEAF_RUNNING( QString argClientIP ) { void lc::Client::SetStateToZLEAF_RUNNING(const QString &argClientIP)
{
if ( argClientIP != ip ) { if ( argClientIP != ip ) {
return; return;
} }
if ( state != state_t::ZLEAF_RUNNING ) { if (state != state_t::ZLEAF_RUNNING) {
pingTimer->stop(); pingTimer->stop();
// Inform the ClientPinger instance, that zLeaf is now running // Inform the ClientPinger instance, that zLeaf is now running
pinger->setStateToZLEAF_RUNNING(); pinger->setStateToZLEAF_RUNNING();
this->GotStatusChanged( state_t::ZLEAF_RUNNING ); this->GotStatusChanged(state_t::ZLEAF_RUNNING);
qDebug() << "Client" << name << "got 'ZLEAF_RUNNING' signal."; qDebug() << "Client" << name << "got 'ZLEAF_RUNNING' signal.";
} }
} }
void lc::Client::ShowDesktopViewOnly() { void lc::Client::ShowDesktopViewOnly()
QStringList arguments; {
arguments << ip; QStringList arguments{ip};
QProcess showDesktopProcess; QProcess showDesktopProcess;
QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); showDesktopProcess.setProcessEnvironment(QProcessEnvironment::systemEnvironment());
showDesktopProcess.setProcessEnvironment( env ); showDesktopProcess.startDetached( settings->vncViewer, QStringList{ip});
showDesktopProcess.startDetached( settings->vncViewer, arguments );
// Output message via the debug messages tab // Output message via the debug messages tab
qDebug() << settings->vncViewer << arguments.join( " " ); qDebug() << settings->vncViewer << arguments.join( " " );
} }
void lc::Client::ShowDesktopFullControl() { void lc::Client::ShowDesktopFullControl()
QStringList arguments; {
arguments << ip + ":5901"; const QStringList arguments{QString{ip + ":5901"}};
QProcess showDesktopProcess; QProcess showDesktopProcess;
QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); showDesktopProcess.setProcessEnvironment(QProcessEnvironment::systemEnvironment());
showDesktopProcess.setProcessEnvironment( env ); showDesktopProcess.startDetached(settings->vncViewer, arguments);
showDesktopProcess.startDetached( settings->vncViewer, arguments );
// Output message via the debug messages tab // Output message via the debug messages tab
qDebug() << settings->vncViewer << arguments.join( " " ); qDebug() << settings->vncViewer << arguments.join(" ");
} }
void lc::Client::Shutdown() { void lc::Client::Shutdown()
if ( state == state_t::NOT_RESPONDING || state == state_t::BOOTING {
|| state == state_t::SHUTTING_DOWN ) { if (state == state_t::NOT_RESPONDING || state == state_t::BOOTING
|| state == state_t::SHUTTING_DOWN) {
return; return;
} }
QStringList arguments; const QStringList arguments{"-i", settings->pkeyPathUser,
arguments << "-i" << settings->pkeyPathUser QString{settings->userNameOnClients + "@" + ip},
<< QString{ settings->userNameOnClients + "@" + ip } << "sudo shutdown -P now"; "sudo shutdown -P now"};
// Start the process // Start the process
QProcess shutdownProcess; QProcess shutdownProcess;
QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); shutdownProcess.setProcessEnvironment(QProcessEnvironment::systemEnvironment());
shutdownProcess.setProcessEnvironment( env ); shutdownProcess.startDetached(settings->sshCmd, arguments);
shutdownProcess.startDetached( settings->sshCmd, arguments );
// Output message via the debug messages tab // Output message via the debug messages tab
qDebug() << settings->sshCmd << arguments.join( " " ); qDebug() << settings->sshCmd << arguments.join(" ");
// This additional 'ping_timer' start is needed for the case that the clients are shut down without prior closing of zLeaves // This additional 'ping_timer' start is needed for the case that the clients are shut down without prior closing of zLeaves
pingTimer->start( 3000 ); pingTimer->start(3000);
protectedCycles = 3; protectedCycles = 3;
GotStatusChanged( state_t::SHUTTING_DOWN ); GotStatusChanged(state_t::SHUTTING_DOWN);
} }
void lc::Client::StartZLeaf( const QString * argFakeName, QString cmd ) { void lc::Client::StartZLeaf(const QString *argFakeName, QString cmd)
if ( state < state_t::RESPONDING || zLeafVersion.isEmpty() || GetSessionPort() < 7000 ) { {
if (state < state_t::RESPONDING
|| zLeafVersion.isEmpty()
|| GetSessionPort() < 7000) {
return; return;
} }
// Create a QMessageBox for user interaction if there is already a zLeaf running // Create a QMessageBox for user interaction if there is already a zLeaf running
std::unique_ptr< QMessageBox > messageBoxRunningZLeafFound; std::unique_ptr<QMessageBox> messageBoxRunningZLeafFound;
if ( state == state_t::ZLEAF_RUNNING ) { if (state == state_t::ZLEAF_RUNNING) {
messageBoxRunningZLeafFound.reset( new QMessageBox{ QMessageBox::Warning, "Running zLeaf found", messageBoxRunningZLeafFound.reset(new QMessageBox{QMessageBox::Warning, "Running zLeaf found",
QString{ "There is already a zLeaf running on " + name + "." }, QString{"There is already a zLeaf running on " + name + "."},
QMessageBox::No | QMessageBox::Yes } ); QMessageBox::No | QMessageBox::Yes});
messageBoxRunningZLeafFound->setInformativeText( "Do you want to start a zLeaf on client " messageBoxRunningZLeafFound->setInformativeText("Do you want to start a zLeaf on client "
+ name + " nonetheless?" ); + name + " nonetheless?");
messageBoxRunningZLeafFound->setDefaultButton( QMessageBox::No ); messageBoxRunningZLeafFound->setDefaultButton(QMessageBox::No);
messageBoxRunningZLeafFound->exec(); messageBoxRunningZLeafFound->exec();
} }
if ( ( messageBoxRunningZLeafFound.get() != nullptr if ((messageBoxRunningZLeafFound.get() != nullptr
&& messageBoxRunningZLeafFound->clickedButton() && messageBoxRunningZLeafFound->clickedButton()
== messageBoxRunningZLeafFound->button( QMessageBox::Yes ) ) == messageBoxRunningZLeafFound->button(QMessageBox::Yes))
|| state != state_t::ZLEAF_RUNNING ) { || state != state_t::ZLEAF_RUNNING) {
QStringList arguments; QStringList arguments;
if ( argFakeName == nullptr ) { if (argFakeName == nullptr) {
arguments << "-i" << settings->pkeyPathUser arguments << "-i" << settings->pkeyPathUser
<< QString{ settings->userNameOnClients + "@" + ip } << QString{settings->userNameOnClients + "@" + ip}
<< cmd; << cmd;
} else { } else {
arguments << "-i" << settings->pkeyPathUser arguments << "-i" << settings->pkeyPathUser
<< QString{ settings->userNameOnClients + "@" + ip } << QString{settings->userNameOnClients + "@" + ip}
<< cmd << cmd
<< "/name" << *argFakeName; << "/name" << *argFakeName;
} }
// Start the process // Start the process
QProcess startZLeafProcess; QProcess startZLeafProcess;
QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); startZLeafProcess.setProcessEnvironment(QProcessEnvironment::systemEnvironment());
startZLeafProcess.setProcessEnvironment( env ); startZLeafProcess.startDetached(settings->sshCmd, arguments);
startZLeafProcess.startDetached( settings->sshCmd, arguments );
// Output message via the debug messages tab // Output message via the debug messages tab
qDebug() << settings->sshCmd << arguments.join( " " ); qDebug() << settings->sshCmd << arguments.join(" ");
} }
} }
void lc::Client::StartClientBrowser( const QString * const argURL, const bool * const argFullscreen ) { void lc::Client::StartClientBrowser(const QString *const argURL,
const bool *const argFullscreen)
{
//Declarations //Declarations
QStringList arguments; QStringList arguments;
// Build arguments list for SSH command // Build arguments list for SSH command
arguments << "-i" << settings->pkeyPathUser arguments << "-i" << settings->pkeyPathUser
<< QString{ settings->userNameOnClients + "@" + ip } << QString{settings->userNameOnClients + "@" + ip}
<< "DISPLAY=:0.0" << "DISPLAY=:0.0"
<< settings->clientBrowserCmd << settings->clientBrowserCmd
<< *argURL; << *argURL;
// Add fullscreen toggle if checked // Add fullscreen toggle if checked
if (*argFullscreen == true){ if (*argFullscreen == true) {
arguments << "& sleep 3 && DISPLAY=:0.0 xdotool key --clearmodifiers F11"; arguments << "& sleep 3 && DISPLAY=:0.0 xdotool key --clearmodifiers F11";
} }
// Start the process // Start the process
QProcess startClientBrowserProcess; QProcess startClientBrowserProcess;
QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); startClientBrowserProcess.setProcessEnvironment(QProcessEnvironment::systemEnvironment());
startClientBrowserProcess.setProcessEnvironment( env ); startClientBrowserProcess.startDetached(settings->sshCmd, arguments);
startClientBrowserProcess.startDetached( settings->sshCmd, arguments );
// Output message via the debug messages tab // Output message via the debug messages tab
qDebug() << settings->sshCmd << arguments.join( " " ); qDebug() << settings->sshCmd << arguments.join(" ");
} }
void lc::Client::StopClientBrowser() { void lc::Client::StopClientBrowser()
{
//Declarations //Declarations
QStringList arguments; QStringList arguments{"-i", settings->pkeyPathUser,
QString{settings->userNameOnClients + "@" + ip},
//Build arguments list "killall", settings->clientBrowserCmd,
arguments << "-i" << settings->pkeyPathUser "& sleep 1 && rm -R /home/ewfuser/.mozilla/firefox/*"};
<< QString{ settings->userNameOnClients + "@" + ip }
<< "killall"
<< settings->clientBrowserCmd
<< "& sleep 1 && rm -R /home/ewfuser/.mozilla/firefox/*";
// Start the process // Start the process
QProcess startClientBrowserProcess; QProcess startClientBrowserProcess;
QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); startClientBrowserProcess.setProcessEnvironment(QProcessEnvironment::systemEnvironment());
startClientBrowserProcess.setProcessEnvironment( env ); startClientBrowserProcess.startDetached(settings->sshCmd, arguments);
startClientBrowserProcess.startDetached( settings->sshCmd, arguments );
// Output message via the debug messages tab // Output message via the debug messages tab
qDebug() << settings->sshCmd << arguments.join( " " ); qDebug() << settings->sshCmd << arguments.join(" ");
} }

@ -1,5 +1,5 @@
/* /*
* Copyright 2014-2016 Markus Prasser * Copyright 2014-2018 Markus Prasser, Tobias Weiss
* *
* This file is part of Labcontrol. * This file is part of Labcontrol.
* *
@ -20,29 +20,27 @@
#ifndef CLIENT_H #ifndef CLIENT_H
#define CLIENT_H #define CLIENT_H
#include <QMessageBox> #include "global.h"
#include <QPlainTextEdit>
#include <QProcess>
#include <QString>
#include <QTextStream>
#include <QThread> #include <QThread>
#include <QTimer>
#include "global.h" class QTimer;
#include "clientpinger.h"
namespace lc { namespace lc {
class ClientPinger;
//! Class which represents the clients in the lab //! Class which represents the clients in the lab
/*! /*!
This class contains elements and functions needed to represent all functions of a client. This class contains elements and functions needed to represent all functions of a client.
*/ */
class Client : public QObject { class Client : public QObject
{
Q_OBJECT Q_OBJECT
public slots: public slots:
//! Sets the STATE of the client to 'ZLEAF_RUNNING' //! Sets the STATE of the client to 'ZLEAF_RUNNING'
void SetStateToZLEAF_RUNNING( QString argClientIP ); void SetStateToZLEAF_RUNNING(const QString &argClientIP);
public: public:
const QString ip; const QString ip;
@ -59,18 +57,20 @@ public:
* \param argXPosition The client's x coordinate in the lab's grid * \param argXPosition The client's x coordinate in the lab's grid
* \param argYPosition The client's y coordinate in the lab's grid * \param argYPosition The client's y coordinate in the lab's grid
*/ */
Client( const QString &argIP, const QString &argMAC, const QString &argName, Client(const QString &argIP, const QString &argMAC, const QString &argName,
unsigned short int argXPosition, unsigned short int argYPosition, const unsigned short int argXPosition,
const QString &argPingCmd ); const unsigned short int argYPosition,
const QString &argPingCmd);
//! Client's destructor //! Client's destructor
~Client(); ~Client() override;
//! Beams the chosen file to the client's 'media4ztree' directory //! Beams the chosen file to the client's 'media4ztree' directory
/*! /*!
@param argFileToBeam The file which shall be beamed to the client's 'media4ztree' directory @param argFileToBeam The file which shall be beamed to the client's 'media4ztree' directory
@param argPublickeyPathUser The path to the publickey for user login on the clients @param argPublickeyPathUser The path to the publickey for user login on the clients
@param argUserNameOnClients The name of the user on the clients @param argUserNameOnClients The name of the user on the clients
*/ */
void BeamFile( const QString &argFileToBeam, const QString * const argPublickeyPathUser, const QString * const argUserNameOnClients ); void BeamFile(const QString &argFileToBeam, const QString *const argPublickeyPathUser,
const QString *const argUserNameOnClients);
/*! /*!
* \brief Boots the client * \brief Boots the client
*/ */
@ -83,8 +83,14 @@ public:
/*! /*!
@return The current state of the client @return The current state of the client
*/ */
state_t GetClientState() const { return state; } state_t GetClientState() const
int GetSessionPort() const { return sessionPort; } {
return state;
}
int GetSessionPort() const
{
return sessionPort;
}
/*! /*!
* \brief Kills all processes 'zleaf.exe' on the client * \brief Kills all processes 'zleaf.exe' on the client
*/ */
@ -93,15 +99,21 @@ public:
/*! /*!
@param argUserToBeUsed The name of the user on the clients @param argUserToBeUsed The name of the user on the clients
*/ */
void OpenFilesystem( const QString * const argUserToBeUsed ); void OpenFilesystem(const QString *const argUserToBeUsed);
/*! /*!
* \brief Opens a terminal for the client * \brief Opens a terminal for the client
* \param argCommand A command which shall be executed in the terminal window (Pass an empty QString if not wanted) * \param argCommand A command which shall be executed in the terminal window (Pass an empty QString if not wanted)
* \param argOpenAsRoot Run the terminal session as root (true) or as normal user (false) * \param argOpenAsRoot Run the terminal session as root (true) or as normal user (false)
*/ */
void OpenTerminal( const QString &argCommand, const bool &argOpenAsRoot ); void OpenTerminal(const QString &argCommand, const bool argOpenAsRoot);
void SetSessionPort( int argSP ) { sessionPort = argSP; } void SetSessionPort(const int argSP)
void SetzLeafVersion( const QString &argzLeafV ) { zLeafVersion = argzLeafV; } {
sessionPort = argSP;
}
void SetzLeafVersion(const QString &argzLeafV)
{
zLeafVersion = argzLeafV;
}
//! Shows the desktop of the given client //! Shows the desktop of the given client
void ShowDesktopViewOnly(); void ShowDesktopViewOnly();
void ShowDesktopFullControl(); void ShowDesktopFullControl();
@ -114,13 +126,13 @@ public:
* \brief Starts a zLeaf instance on the client * \brief Starts a zLeaf instance on the client
* @param argFakeName The name the zLeaf instance shall have (if not the default, which is the hostname of the client) * @param argFakeName The name the zLeaf instance shall have (if not the default, which is the hostname of the client)
*/ */
void StartZLeaf(const QString *argFakeName = nullptr, QString cmd = "" ); void StartZLeaf(const QString *argFakeName = nullptr, QString cmd = "");
/*! /*!
* \brief Opens a browser window on the client * \brief Opens a browser window on the client
* @param argURL URL to open in clients browser * @param argURL URL to open in clients browser
*/ */
void StartClientBrowser( const QString *argURL = nullptr, const bool *argFullscreen = nullptr ); void StartClientBrowser(const QString *argURL = nullptr, const bool *argFullscreen = nullptr);
/*! /*!
* \brief Closes all browser instances * \brief Closes all browser instances
@ -128,24 +140,28 @@ public:
void StopClientBrowser(); void StopClientBrowser();
private: private:
const QString &GetzLeafVersion() const { return zLeafVersion; } const QString &GetzLeafVersion() const
{
return zLeafVersion;
}
unsigned short int protectedCycles; unsigned short int protectedCycles;
ClientPinger *pinger = nullptr; ClientPinger *pinger = nullptr;
QThread pingerThread; QThread pingerThread;
state_t state = state_t::UNINITIALIZED; state_t state = state_t::UNINITIALIZED;
QTimer *pingTimer = nullptr; //! QTimer used to trigger pings by pinger's ClientPinger instance //! QTimer used to trigger pings by pinger's ClientPinger instance
QTimer *pingTimer = nullptr;
int sessionPort = 0; int sessionPort = 0;
QString zLeafVersion; QString zLeafVersion;
private slots: private slots:
void GotStatusChanged( state_t argState ); void GotStatusChanged(const state_t argState);
void RequestAPing(); void RequestAPing();
signals: signals:
void PingWanted(); void PingWanted();
}; };
} } // namespace lc
#endif // CLIENT_H #endif // CLIENT_H

@ -17,11 +17,19 @@
* along with Labcontrol. If not, see <http://www.gnu.org/licenses/>. * along with Labcontrol. If not, see <http://www.gnu.org/licenses/>.
*/ */
/* #include "manualprintingsetup.h"
#include "ui_manualprintingsetup.h"
#include "Lib/settings.h"
#include <QFileDialog>
*/
#include "manualprintingsetup.h" #include "manualprintingsetup.h"
#include "ui_manualprintingsetup.h" #include "ui_manualprintingsetup.h"
#include "Lib/settings.h" #include "Lib/settings.h"
#include <QFileDialog> #include <QFileDialog>
#include <QMessageBox>
#include <memory> #include <memory>

@ -45,7 +45,7 @@ signals:
private: private:
QString dateString; QString dateString;
Ui::ManualPrintingSetup *ui = nullptr; Ui::ManualPrintingSetup *const ui = nullptr;
QString workPath; QString workPath;
private slots: private slots:

Loading…
Cancel
Save