Made function arguments for 'lc::Client' class consistent

remotes/origin/HEAD
markuspg 8 years ago
parent 598e68855a
commit e68d404056

@ -26,12 +26,11 @@
extern std::unique_ptr< lc::Settings > settings;
lc::Client::Client( QString *argIP, QString *argMAC,
QString *argName, unsigned short int argXPosition,
unsigned short int argYPosition ):
ip{ *argIP },
mac{ *argMAC },
name{ *argName },
lc::Client::Client( const QString &argIP, const QString &argMAC, const QString &argName,
unsigned short int argXPosition, unsigned short int argYPosition ):
ip{ argIP },
mac{ argMAC },
name{ argName },
xPosition{ argXPosition },
yPosition{ argYPosition },
protectedCycles{ 0 }
@ -88,8 +87,8 @@ void lc::Client::BeamFile( const QString &argFileToBeam, const QString * const a
qDebug() << settings->scpCmd << arguments.join( " " );
}
void lc::Client::Boot( const QString &argNetworkBroadcastAddress ) {
QStringList arguments{ QStringList{} << "-i" << argNetworkBroadcastAddress << mac };
void lc::Client::Boot() {
QStringList arguments{ QStringList{} << "-i" << settings->netwBrdAddr << mac };
// Start the process
QProcess wakeonlanProcess;
@ -106,10 +105,10 @@ void lc::Client::Boot( const QString &argNetworkBroadcastAddress ) {
GotStatusChanged( state_t::BOOTING );
}
void lc::Client::DeactiveScreensaver( const QString &argPublickeyPathUser,
const QString &argUserNameOnClients ) {
void lc::Client::DeactiveScreensaver() {
QStringList arguments;
arguments << "-i" << argPublickeyPathUser << QString{ argUserNameOnClients + "@" + ip }
arguments << "-i" << settings->pkeyPathUser
<< QString{ settings->userNameOnClients + "@" + ip }
<< settings->xsetCmd << "-display" << ":0.0" << "dpms" << "force" << "on";
// Start the process
@ -170,9 +169,7 @@ void lc::Client::OpenFilesystem( const QString * const argUserToBeUsed ) {
qDebug() << settings->fileMngr << arguments.join( " " );
}
void lc::Client::OpenTerminal( const QString &argCommand, const bool &argOpenAsRoot,
const QString & argPublickeyPathUser,
const QString &argUserNameOnClients ) {
void lc::Client::OpenTerminal( const QString &argCommand, const bool &argOpenAsRoot ) {
if ( !settings->termEmulCmd.isEmpty() ) {
if ( state < state_t::RESPONDING ) {
return;
@ -182,11 +179,11 @@ void lc::Client::OpenTerminal( const QString &argCommand, const bool &argOpenAsR
arguments = new QStringList;
if ( !argOpenAsRoot ) {
*arguments << "--title" << name << "-e" <<
QString{ settings->sshCmd + " -i " + argPublickeyPathUser + " "
+ argUserNameOnClients + "@" + ip };
QString{ settings->sshCmd + " -i " + settings->pkeyPathUser + " "
+ settings->userNameOnClients + "@" + ip };
} else {
*arguments << "--title" << name << "-e" <<
QString{ settings->sshCmd + " -i " + argPublickeyPathUser + " " + "root@" + ip };
QString{ settings->sshCmd + " -i " + settings->pkeyPathRoot + " " + "root@" + ip };
}
if ( settings->termEmulCmd.contains( "konsole" ) ) {
@ -244,12 +241,13 @@ void lc::Client::ShowDesktop() {
qDebug() << settings->vncViewer << arguments.join( " " );
}
void lc::Client::Shutdown( const QString &argPublickeyPathUser, const QString &argUserNameOnClients ) {
void lc::Client::Shutdown() {
if ( state == state_t::NOT_RESPONDING || state == state_t::BOOTING || state == state_t::SHUTTING_DOWN ) {
return;
}
QStringList arguments;
arguments << "-i" << argPublickeyPathUser << QString{ argUserNameOnClients + "@" + ip } << "sudo shutdown -P now";
arguments << "-i" << settings->pkeyPathUser
<< QString{ settings->userNameOnClients + "@" + ip } << "sudo shutdown -P now";
// Start the process
QProcess shutdownProcess;

@ -51,18 +51,16 @@ public:
const unsigned short int xPosition = 1;
const unsigned short int yPosition = 1;
//! Client's constructor
/*!
@param argDebugMessagesTextEditPtr A pointer to the debug messages text edit for verbose output
@param argIP The IP address the represented client has
@param argMAC The MAC address the represented client has
@param argName The hostname of the represented client
@param argXPosition The client's x coordinate in the lab
@param argYPosition The client's y coordinate in the lab
@param argSettingsItems A QVector storing many needed data QStrings
*/
Client( QString *argIP, QString *argMAC,
QString *argName, unsigned short int argXPosition, unsigned short int argYPosition );
* \brief Client's constructor
* \param argIP The IP address the represented client has
* \param argMAC The MAC address the represented client has
* \param argName The hostname of the represented client
* \param argXPosition The client's x 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,
unsigned short int argXPosition, unsigned short int argYPosition );
//! Client's destructor
~Client();
//! Beams the chosen file to the client's 'media4ztree' directory
@ -72,18 +70,14 @@ public:
@param argUserNameOnClients The name of the user on the clients
*/
void BeamFile( const QString &argFileToBeam, const QString * const argPublickeyPathUser, const QString * const argUserNameOnClients );
//! Boots the client
/*!
@param argNetworkBroadcastAddress The network broadcast address of the lab
*/
void Boot( const QString &argNetworkBroadcastAddress );
//! Runs the 'deactivate_screensaver.sh' script on the client to deactivate the screensaver
* \brief Boots the client
*/
void Boot();
/*!
@param argPublickeyPathUser The path to the publickey for user login on the clients
@param argUserNameOnClients The name of the user on the clients
*/
void DeactiveScreensaver( const QString &argPublickeyPathUser,
const QString &argUserNameOnClients );
* \brief DeactiveScreensaver deactivates potentially running screensavers on the client
*/
void DeactiveScreensaver();
//! Returns the current state of the client
/*!
@return The current state of the client
@ -98,24 +92,18 @@ public:
@param argUserToBeUsed The name of the user on the clients
*/
void OpenFilesystem( const QString * const argUserToBeUsed );
//! 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 argOpenAsRoot Run the terminal session as root (true) or as normal user (false)
@param argPublickeyPathUser The path to the publickey for user login on the clients
@param argUserNameOnClients The name of the user on the clients
*/
void OpenTerminal( const QString &argCommand, const bool &argOpenAsRoot,
const QString &argPublickeyPathUser,
const QString &argUserNameOnClients );
* \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 argOpenAsRoot Run the terminal session as root (true) or as normal user (false)
*/
void OpenTerminal( const QString &argCommand, const bool &argOpenAsRoot );
//! Shows the desktop of the given client
void ShowDesktop();
//! Shuts down the client
/*!
@param argPublickeyPathUser The path to the publickey for user login on the clients
@param argUserNameOnClients The name of the user on the clients
*/
void Shutdown( const QString &argPublickeyPathUser, const QString &argUserNameOnClients );
* \brief Shuts down the client
*/
void Shutdown();
//! Starts a zLeaf instance on the client
/*!
@param argZTreeVersion The version of zLeaf which shall be started

@ -236,8 +236,8 @@ void lc::Lablib::ReadSettings() {
clients = new QVector< Client* >;
for ( int i = 0; i < clientQuantity; i++ ) {
clients->append( new Client{ &clientIPs[ i ], &clientMACs[ i ],
&clientNames[ i ], clientXPositions[ i ].toUShort(),
clients->append( new Client{ clientIPs[ i ], clientMACs[ i ], clientNames[ i ],
clientXPositions[ i ].toUShort(),
clientYPositions[ i ].toUShort() } );
// Add an corresponding entry to the 'client_ips_to_clients_map' std::map<QString, Client*>

@ -245,7 +245,7 @@ void lc::MainWindow::on_PBBoot_clicked() {
for ( QModelIndexList::ConstIterator it = activatedItems.cbegin(); it != activatedItems.cend(); ++it ) {
if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) {
Client *client = static_cast< Client* >( ( *it ).data( Qt::UserRole ).value< void * >() );
client->Boot( settings->netwBrdAddr );
client->Boot();
}
}
}
@ -272,7 +272,7 @@ void lc::MainWindow::on_PBDeactivateScreensaver_clicked() {
QVector< Client* > *clients = lablib->GetClients();
for ( auto s : *clients ) {
if ( s->GetClientState() >= state_t::RESPONDING )
s->DeactiveScreensaver( settings->pkeyPathUser, settings->userNameOnClients );
s->DeactiveScreensaver();
}
}
@ -316,8 +316,7 @@ void lc::MainWindow::on_PBExecute_clicked() {
qDebug() << "Executing command" << command << "on every client.";
for ( auto s: *clients ) {
if ( !( s->name.contains( "backup", Qt::CaseInsensitive ) ) ) {
s->OpenTerminal( command, ui->RBUseUserRoot->isChecked(), pkeyPathUser,
settings->userNameOnClients );
s->OpenTerminal( command, ui->RBUseUserRoot->isChecked() );
}
}
} else {
@ -326,8 +325,7 @@ void lc::MainWindow::on_PBExecute_clicked() {
for ( QModelIndexList::ConstIterator it = activated_items.cbegin(); it != activated_items.cend(); ++it ) {
if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) {
Client *client = static_cast< Client* >( ( *it ).data( Qt::UserRole ).value< void * >() );
client->OpenTerminal( command, ui->RBUseUserRoot->isChecked(), pkeyPathUser,
settings->userNameOnClients );
client->OpenTerminal( command, ui->RBUseUserRoot->isChecked() );
}
}
}
@ -392,8 +390,7 @@ void lc::MainWindow::on_PBOpenTerminal_clicked() {
for ( QModelIndexList::ConstIterator it = activated_items.cbegin(); it != activated_items.cend(); ++it ) {
if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) {
Client *client = static_cast< Client* >( ( *it ).data( Qt::UserRole ).value< void * >() );
client->OpenTerminal( QString{}, ui->RBUseUserRoot->isChecked(),
pkeyPathUser, settings->userNameOnClients );
client->OpenTerminal( QString{}, ui->RBUseUserRoot->isChecked() );
}
}
}
@ -476,7 +473,7 @@ void lc::MainWindow::on_PBShutdown_clicked() {
for ( QModelIndexList::ConstIterator it = activatedItems.cbegin(); it != activatedItems.cend(); ++it ) {
if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) {
Client *client = static_cast< Client* >( ( *it ).data( Qt::UserRole ).value< void * >() );
client->Shutdown( settings->pkeyPathUser, settings->userNameOnClients );
client->Shutdown();
}
}
}

Loading…
Cancel
Save