Began refactoring and reformatting the code

remotes/origin/HEAD
markuspg 10 years ago
parent 90e65ce0bf
commit 8180c03c45

@ -35,8 +35,8 @@ lc::Client::Client( QPlainTextEdit *argDebugMessagesTextEdit, QString *argIP, QS
{ {
qRegisterMetaType< state_t >( "STATE" ); qRegisterMetaType< state_t >( "STATE" );
if ( ( *settingsItems )[ ( int )settingsItems_t::PING_COMMAND ] ) { if ( ( *settingsItems )[ ( int )settItms_t::PING_COMMAND ] ) {
pinger = new ClientPinger{ &ip, ( *settingsItems )[ ( int )settingsItems_t::PING_COMMAND ] }; pinger = new ClientPinger{ &ip, ( *settingsItems )[ ( int )settItms_t::PING_COMMAND ] };
pinger->moveToThread( &pingerThread ); pinger->moveToThread( &pingerThread );
connect( &pingerThread, &QThread::finished, connect( &pingerThread, &QThread::finished,
pinger, &QObject::deleteLater ); pinger, &QObject::deleteLater );
@ -79,9 +79,9 @@ void lc::Client::BeamFile( const QString &argFileToBeam, const QString * const a
QProcess beamFileProcess; QProcess beamFileProcess;
QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
beamFileProcess.setProcessEnvironment( env ); beamFileProcess.setProcessEnvironment( env );
beamFileProcess.startDetached( *( *settingsItems )[ ( int )settingsItems_t::RCP_COMMAND ], arguments ); beamFileProcess.startDetached( *( *settingsItems )[ ( int )settItms_t::RCP_CMD ], arguments );
debugMessagesTextEdit->appendPlainText( "[DEBUG] " + *( *settingsItems )[ ( int )settingsItems_t::RCP_COMMAND ] + " " + arguments.join( " " ) ); debugMessagesTextEdit->appendPlainText( "[DEBUG] " + *( *settingsItems )[ ( int )settItms_t::RCP_CMD ] + " " + arguments.join( " " ) );
} }
void lc::Client::Boot( const QString * const argNetworkBroadcastAddress ) { void lc::Client::Boot( const QString * const argNetworkBroadcastAddress ) {
@ -95,11 +95,11 @@ void lc::Client::Boot( const QString * const argNetworkBroadcastAddress ) {
QProcess wakeonlanProcess; QProcess wakeonlanProcess;
QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
wakeonlanProcess.setProcessEnvironment( env ); wakeonlanProcess.setProcessEnvironment( env );
wakeonlanProcess.startDetached( *( *settingsItems )[ ( int )settingsItems_t::WAKEONLAN_COMMAND ], arguments ); wakeonlanProcess.startDetached( *( *settingsItems )[ ( int )settItms_t::WAKEONLAN_CMD ], arguments );
// Output message via the debug messages tab // Output message via the debug messages tab
debugMessagesTextEdit->appendPlainText( "[DEBUG] " + debugMessagesTextEdit->appendPlainText( "[DEBUG] " +
*( *settingsItems )[ ( int )settingsItems_t::WAKEONLAN_COMMAND ] +" " + arguments.join( " " ) ); *( *settingsItems )[ ( int )settItms_t::WAKEONLAN_CMD ] +" " + arguments.join( " " ) );
pingTimer->start( 3000 ); pingTimer->start( 3000 );
@ -110,16 +110,16 @@ void lc::Client::Boot( const QString * const argNetworkBroadcastAddress ) {
void lc::Client::DeactiveScreensaver( const QString * const argPublickeyPathUser, const QString * const argUserNameOnClients ) { void lc::Client::DeactiveScreensaver( const QString * const argPublickeyPathUser, const QString * const argUserNameOnClients ) {
QStringList arguments; QStringList arguments;
arguments << "-i" << *argPublickeyPathUser << QString{ *argUserNameOnClients + "@" + name } arguments << "-i" << *argPublickeyPathUser << QString{ *argUserNameOnClients + "@" + name }
<< *( *settingsItems )[ ( int )settingsItems_t::XSET_COMMAND ] << "-display" << ":0.0" << "dpms" << "force" << "on"; << *( *settingsItems )[ ( int )settItms_t::XSET_CMD ] << "-display" << ":0.0" << "dpms" << "force" << "on";
// Start the process // Start the process
QProcess deactiveScreensaverProcess; QProcess deactiveScreensaverProcess;
QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
deactiveScreensaverProcess.setProcessEnvironment( env ); deactiveScreensaverProcess.setProcessEnvironment( env );
deactiveScreensaverProcess.startDetached( *( *settingsItems )[ ( int )settingsItems_t::SSH_COMMAND ], arguments ); deactiveScreensaverProcess.startDetached( *( *settingsItems )[ ( int )settItms_t::SSH_CMD ], arguments );
// Output message via the debug messages tab // Output message via the debug messages tab
debugMessagesTextEdit->appendPlainText("[DEBUG] " + *( *settingsItems )[ ( int )settingsItems_t::SSH_COMMAND ] + " " + arguments.join(" ")); debugMessagesTextEdit->appendPlainText("[DEBUG] " + *( *settingsItems )[ ( int )settItms_t::SSH_CMD ] + " " + arguments.join(" "));
} }
// void Client::display_ping_string(QString *ping_string) { // void Client::display_ping_string(QString *ping_string) {
@ -141,16 +141,16 @@ void lc::Client::GotStatusChanged( state_t argState ) {
void lc::Client::KillZLeaf( const QString * const argPublickeyPathUser, const QString * const argUserNameOnClients ) { void lc::Client::KillZLeaf( const QString * const argPublickeyPathUser, const QString * const argUserNameOnClients ) {
QStringList arguments; QStringList arguments;
arguments << "-i" << *argPublickeyPathUser << QString{ *argUserNameOnClients + "@" + name } arguments << "-i" << *argPublickeyPathUser << QString{ *argUserNameOnClients + "@" + name }
<< QString{ *( *settingsItems )[ ( int )settingsItems_t::LABCONTROL_INSTALLATION_DIRECTORY ] + "/scripts/kill_zLeaf_labcontrol2.sh" }; << QString{ *( *settingsItems )[ ( int )settItms_t::LC_INST_DIR ] + "/scripts/kill_zLeaf_labcontrol2.sh" };
// Start the process // Start the process
QProcess killZLeafProcess; QProcess killZLeafProcess;
QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
killZLeafProcess.setProcessEnvironment( env ); killZLeafProcess.setProcessEnvironment( env );
killZLeafProcess.startDetached( *( *settingsItems )[ ( int )settingsItems_t::SSH_COMMAND ], arguments ); killZLeafProcess.startDetached( *( *settingsItems )[ ( int )settItms_t::SSH_CMD ], arguments );
// Output message via the debug messages tab // Output message via the debug messages tab
debugMessagesTextEdit->appendPlainText( "[DEBUG] " + *( *settingsItems )[ ( int )settingsItems_t::SSH_COMMAND ] + " " + arguments.join( " " ) ); debugMessagesTextEdit->appendPlainText( "[DEBUG] " + *( *settingsItems )[ ( int )settItms_t::SSH_CMD ] + " " + 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 );
@ -165,12 +165,12 @@ void lc::Client::OpenFilesystem( const QString * const argUserToBeUsed ) {
QProcess openFilesystemProcess; QProcess openFilesystemProcess;
QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
openFilesystemProcess.setProcessEnvironment( env ); openFilesystemProcess.setProcessEnvironment( env );
openFilesystemProcess.startDetached( *( *settingsItems )[ ( int )settingsItems_t::FILE_MANAGER ], arguments ); openFilesystemProcess.startDetached( *( *settingsItems )[ ( int )settItms_t::FILE_MANAGER ], arguments );
debugMessagesTextEdit->appendPlainText( "[DEBUG] " + *( *settingsItems )[ ( int )settingsItems_t::FILE_MANAGER ] + " " + arguments.join( " " ) ); debugMessagesTextEdit->appendPlainText( "[DEBUG] " + *( *settingsItems )[ ( int )settItms_t::FILE_MANAGER ] + " " + arguments.join( " " ) );
} }
void lc::Client::OpenTerminal( const QString &argCommand, const bool &argOpenAsRoot, const QString * const argPublickeyPathUser, const QString * const argUserNameOnClients ) { void lc::Client::OpenTerminal( const QString &argCommand, const bool &argOpenAsRoot, const QString * const argPublickeyPathUser, const QString * const argUserNameOnClients ) {
if ( ( *settingsItems )[ ( int )settingsItems_t::TERMINAL_EMULATOR_COMMAND ] ) { if ( ( *settingsItems )[ ( int )settItms_t::TERM_EMUL_CMD ] ) {
if ( state < state_t::RESPONDING ) { if ( state < state_t::RESPONDING ) {
return; return;
} }
@ -179,17 +179,17 @@ void lc::Client::OpenTerminal( const QString &argCommand, const bool &argOpenAsR
arguments = new QStringList; arguments = new QStringList;
if ( !argOpenAsRoot ) { if ( !argOpenAsRoot ) {
*arguments << "--title" << name << "-e" << *arguments << "--title" << name << "-e" <<
QString{ *( *settingsItems )[ ( int )settingsItems_t::SSH_COMMAND ] + " -i " + *argPublickeyPathUser + " " + *argUserNameOnClients + "@" + name }; QString{ *( *settingsItems )[ ( int )settItms_t::SSH_CMD ] + " -i " + *argPublickeyPathUser + " " + *argUserNameOnClients + "@" + name };
} else { } else {
*arguments << "--title" << name << "-e" << *arguments << "--title" << name << "-e" <<
QString{ *( *settingsItems )[ ( int )settingsItems_t::SSH_COMMAND ] + " -i " + *argPublickeyPathUser + " " + "root@" + name }; QString{ *( *settingsItems )[ ( int )settItms_t::SSH_CMD ] + " -i " + *argPublickeyPathUser + " " + "root@" + name };
} }
if ( ( *settingsItems )[ ( int )settingsItems_t::TERMINAL_EMULATOR_COMMAND ]->contains( "konsole" ) ) { if ( ( *settingsItems )[ ( int )settItms_t::TERM_EMUL_CMD ]->contains( "konsole" ) ) {
arguments->prepend( "--new-tab" ); arguments->prepend( "--new-tab" );
arguments->prepend( "--show-tabbar" ); arguments->prepend( "--show-tabbar" );
} else { } else {
if ( ( *settingsItems )[ ( int )settingsItems_t::TERMINAL_EMULATOR_COMMAND ]->contains( "gnome-terminal" ) ) { if ( ( *settingsItems )[ ( int )settItms_t::TERM_EMUL_CMD ]->contains( "gnome-terminal" ) ) {
arguments->prepend( "--tab" ); arguments->prepend( "--tab" );
} }
} }
@ -201,9 +201,9 @@ void lc::Client::OpenTerminal( const QString &argCommand, const bool &argOpenAsR
QProcess openTerminalProcess; QProcess openTerminalProcess;
QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
openTerminalProcess.setProcessEnvironment( env ); openTerminalProcess.setProcessEnvironment( env );
openTerminalProcess.startDetached( *( *settingsItems )[ ( int )settingsItems_t::TERMINAL_EMULATOR_COMMAND ], *arguments ); openTerminalProcess.startDetached( *( *settingsItems )[ ( int )settItms_t::TERM_EMUL_CMD ], *arguments );
debugMessagesTextEdit->appendPlainText("[DEBUG] " + debugMessagesTextEdit->appendPlainText("[DEBUG] " +
*( *settingsItems )[ ( int )settingsItems_t::TERMINAL_EMULATOR_COMMAND ] + " " + arguments->join(" ")); *( *settingsItems )[ ( int )settItms_t::TERM_EMUL_CMD ] + " " + arguments->join(" "));
delete arguments; delete arguments;
} }
} }
@ -235,10 +235,10 @@ void lc::Client::ShowDesktop() {
QProcess showDesktopProcess; QProcess showDesktopProcess;
QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
showDesktopProcess.setProcessEnvironment( env ); showDesktopProcess.setProcessEnvironment( env );
showDesktopProcess.startDetached( *( *settingsItems )[ ( int )settingsItems_t::VNC_VIEWER ], arguments ); showDesktopProcess.startDetached( *( *settingsItems )[ ( int )settItms_t::VNC_VIEWER ], arguments );
// Output message via the debug messages tab // Output message via the debug messages tab
debugMessagesTextEdit->appendPlainText( "[DEBUG] " + *( *settingsItems )[ ( int )settingsItems_t::VNC_VIEWER ] + " " + arguments.join( " " ) ); debugMessagesTextEdit->appendPlainText( "[DEBUG] " + *( *settingsItems )[ ( int )settItms_t::VNC_VIEWER ] + " " + arguments.join( " " ) );
} }
void lc::Client::Shutdown( const QString * const argPublickeyPathUser, const QString * const argUserNameOnClients ) { void lc::Client::Shutdown( const QString * const argPublickeyPathUser, const QString * const argUserNameOnClients ) {
@ -252,10 +252,10 @@ void lc::Client::Shutdown( const QString * const argPublickeyPathUser, const QSt
QProcess shutdownProcess; QProcess shutdownProcess;
QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
shutdownProcess.setProcessEnvironment( env ); shutdownProcess.setProcessEnvironment( env );
shutdownProcess.startDetached( *( *settingsItems )[ ( int )settingsItems_t::SSH_COMMAND ], arguments ); shutdownProcess.startDetached( *( *settingsItems )[ ( int )settItms_t::SSH_CMD ], arguments );
// Output message via the debug messages tab // Output message via the debug messages tab
debugMessagesTextEdit->appendPlainText( "[DEBUG] " + *( *settingsItems )[ ( int )settingsItems_t::SSH_COMMAND ] + " " + arguments.join( " " ) ); debugMessagesTextEdit->appendPlainText( "[DEBUG] " + *( *settingsItems )[ ( int )settItms_t::SSH_CMD ] + " " + 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 );
@ -299,10 +299,10 @@ void lc::Client::StartZLeaf( const QString * const argPublickeyPathUser, const Q
QProcess startZLeafProcess; QProcess startZLeafProcess;
QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
startZLeafProcess.setProcessEnvironment( env ); startZLeafProcess.setProcessEnvironment( env );
startZLeafProcess.startDetached( *( *settingsItems )[ ( int )settingsItems_t::SSH_COMMAND ], arguments ); startZLeafProcess.startDetached( *( *settingsItems )[ ( int )settItms_t::SSH_CMD ], arguments );
// Output message via the debug messages tab // Output message via the debug messages tab
debugMessagesTextEdit->appendPlainText( "[DEBUG] " + *( *settingsItems )[ ( int )settingsItems_t::SSH_COMMAND ] + " " + arguments.join( " " ) ); debugMessagesTextEdit->appendPlainText( "[DEBUG] " + *( *settingsItems )[ ( int )settItms_t::SSH_CMD ] + " " + arguments.join( " " ) );
} }
delete messageBoxRunningZLeafFound; delete messageBoxRunningZLeafFound;
} }

@ -22,10 +22,12 @@
#include <QMetaType> #include <QMetaType>
enum class settingsItems_t : unsigned short int { DVIPS_COMMAND, FILE_MANAGER, LABCONTROL_INSTALLATION_DIRECTORY, LATEX_COMMAND, LOCAL_ZLEAF_NAME, LPR_COMMAND, enum class settItms_t : unsigned short int { DVIPS_CMD, FILE_MANAGER, LC_INST_DIR,
NETSTAT_COMMAND, NETWORK_BROADCAST_ADDRESS, ORSEE_COMMAND, PING_COMMAND, POSTSCRIPT_VIEWER, PS2PDF_COMMAND, LATEX_CMD, LOCAL_ZLEAF_NAME, LPR_CMD, NETSTAT_CMD, NETW_BRDCAST_ADDR,
PUBLICKEY_PATH_ROOT, PUBLICKEY_PATH_USER, RCP_COMMAND, RM_COMMAND, SERVER_IP, SSH_COMMAND, TERMINAL_EMULATOR_COMMAND, ORSEE_COMMAND, PING_COMMAND, POSTSCRIPT_VIEWER, PS2PDF_COMMAND,
USER_NAME_ON_CLIENTS, VNC_VIEWER, WAKEONLAN_COMMAND, WMCTRL_COMMAND, XSET_COMMAND, ZTREE_INSTALLATION_DIRECTORY, SETTINGS_ITEMS_QUANTITY }; SSH_KEY_ROOT, SSH_KEY_USER, RCP_CMD, RM_CMD, SERVER_IP, SSH_CMD,
TERM_EMUL_CMD, USER_NAME_ON_CLIENTS, VNC_VIEWER, WAKEONLAN_CMD,
WMCTRL_CMD, XSET_CMD, ZTREE_INST_DIR, SETT_ITMS_QUANT };
//! Opens a terminal for the client //! Opens a terminal for the client
enum class state_t : unsigned short int { enum class state_t : unsigned short int {

@ -30,16 +30,15 @@ lc::Lablib::Lablib( QPlainTextEdit *argDebugMessagesTextEdit, QObject *argParent
labSettings{ "Economic Laboratory", "Labcontrol", this }, labSettings{ "Economic Laboratory", "Labcontrol", this },
occupiedPorts{ new QVector< int > }, occupiedPorts{ new QVector< int > },
sessionsModel{ new SessionsModel{ this } }, sessionsModel{ new SessionsModel{ this } },
settingsItems{ new QVector< QString* >{ ( int )settingsItems_t::SETTINGS_ITEMS_QUANTITY, nullptr } } settingsItems{ new QVector< QString* >{ ( int )settItms_t::SETT_ITMS_QUANT, nullptr } }
{ {
ReadSettings(); ReadSettings();
DetectInstalledZTreeVersionsAndLaTeXHeaders(); DetectInstalledZTreeVersionsAndLaTeXHeaders();
// Initialize all 'netstat' query mechanisms // Initialize all 'netstat' query mechanisms
if ( ( *settingsItems )[ ( int )settingsItems_t::NETSTAT_COMMAND ] ) { if ( ( *settingsItems )[ ( int )settItms_t::NETSTAT_CMD ] ) {
netstatAgent = new NetstatAgent{ ( *settingsItems )[ ( int )settingsItems_t::NETSTAT_COMMAND ] }; netstatAgent = new NetstatAgent{ ( *settingsItems )[ ( int )settItms_t::NETSTAT_CMD ] };
netstatAgent->moveToThread( &netstatThread ); netstatAgent->moveToThread( &netstatThread );
connect( &netstatThread, &QThread::finished, netstatAgent, &QObject::deleteLater ); connect( &netstatThread, &QThread::finished, netstatAgent, &QObject::deleteLater );
connect( netstatAgent, &NetstatAgent::QueryFinished, connect( netstatAgent, &NetstatAgent::QueryFinished,
@ -52,8 +51,8 @@ lc::Lablib::Lablib( QPlainTextEdit *argDebugMessagesTextEdit, QObject *argParent
} }
// Initialize the server for client help requests retrieval // Initialize the server for client help requests retrieval
if ( clientHelpNotificationServerPort && ( *settingsItems )[ ( int )settingsItems_t::SERVER_IP ] ) { if ( clientHelpNotificationServerPort && ( *settingsItems )[ ( int )settItms_t::SERVER_IP ] ) {
clientHelpNotificationServer = new ClientHelpNotificationServer{ clientIPsToClientsMap,( *settingsItems )[ ( int )settingsItems_t::SERVER_IP ], clientHelpNotificationServerPort, this }; clientHelpNotificationServer = new ClientHelpNotificationServer{ clientIPsToClientsMap,( *settingsItems )[ ( int )settItms_t::SERVER_IP ], clientHelpNotificationServerPort, this };
} }
} }
@ -94,16 +93,16 @@ bool lc::Lablib::CheckPathAndComplain( const QString * const argPath,
void lc::Lablib::DetectInstalledZTreeVersionsAndLaTeXHeaders() { void lc::Lablib::DetectInstalledZTreeVersionsAndLaTeXHeaders() {
// Detect the installed LaTeX headers // Detect the installed LaTeX headers
if ( ( *settingsItems )[ ( int )settingsItems_t::LABCONTROL_INSTALLATION_DIRECTORY ] ) { if ( ( *settingsItems )[ ( int )settItms_t::LC_INST_DIR ] ) {
QDir laTeXDirectory{ *( *settingsItems )[ ( int )settingsItems_t::LABCONTROL_INSTALLATION_DIRECTORY ], "*header.tex", QDir::Name, QDir::CaseSensitive | QDir::Files | QDir::Readable }; QDir laTeXDirectory{ *( *settingsItems )[ ( int )settItms_t::LC_INST_DIR ], "*header.tex", QDir::Name, QDir::CaseSensitive | QDir::Files | QDir::Readable };
if ( !laTeXDirectory.exists() || laTeXDirectory.entryList().isEmpty() ) { if ( !laTeXDirectory.exists() || laTeXDirectory.entryList().isEmpty() ) {
QMessageBox messageBox{ QMessageBox::Critical, tr( "No LaTeX headers found" ), QMessageBox messageBox{ QMessageBox::Critical, tr( "No LaTeX headers found" ),
tr( "No LaTeX headers could be found in '%1'. Receipts printing will not work" ) tr( "No LaTeX headers could be found in '%1'. Receipts printing will not work" )
.arg( *( *settingsItems )[ ( int )settingsItems_t::LABCONTROL_INSTALLATION_DIRECTORY ] ), QMessageBox::Ok }; .arg( *( *settingsItems )[ ( int )settItms_t::LC_INST_DIR ] ), QMessageBox::Ok };
messageBox.exec(); messageBox.exec();
installedLaTeXHeaders = new QStringList{ "None found" }; installedLaTeXHeaders = new QStringList{ "None found" };
debugMessagesTextEdit->appendPlainText( tr( "[DEBUG] No LaTeX headers could be found in '%1'." ) debugMessagesTextEdit->appendPlainText( tr( "[DEBUG] No LaTeX headers could be found in '%1'." )
.arg( *( *settingsItems )[ ( int )settingsItems_t::LABCONTROL_INSTALLATION_DIRECTORY ] ) ); .arg( *( *settingsItems )[ ( int )settItms_t::LC_INST_DIR ] ) );
} else { } else {
installedLaTeXHeaders = new QStringList{ laTeXDirectory.entryList() }; installedLaTeXHeaders = new QStringList{ laTeXDirectory.entryList() };
installedLaTeXHeaders->replaceInStrings( "_header.tex", "" ); installedLaTeXHeaders->replaceInStrings( "_header.tex", "" );
@ -112,15 +111,15 @@ void lc::Lablib::DetectInstalledZTreeVersionsAndLaTeXHeaders() {
} }
// Detect the installed zTree versions // Detect the installed zTree versions
if ( ( *settingsItems )[ ( int )settingsItems_t::ZTREE_INSTALLATION_DIRECTORY ] ) { if ( ( *settingsItems )[ ( int )settItms_t::ZTREE_INST_DIR ] ) {
QDir zTreeDirectory{ *( *settingsItems )[ ( int )settingsItems_t::ZTREE_INSTALLATION_DIRECTORY ], "zTree*", QDir::Name, QDir::NoDotAndDotDot | QDir::Dirs | QDir::Readable | QDir::CaseSensitive }; QDir zTreeDirectory{ *( *settingsItems )[ ( int )settItms_t::ZTREE_INST_DIR ], "zTree*", QDir::Name, QDir::NoDotAndDotDot | QDir::Dirs | QDir::Readable | QDir::CaseSensitive };
if ( zTreeDirectory.entryList().isEmpty() ) { if ( zTreeDirectory.entryList().isEmpty() ) {
QMessageBox messageBox{ QMessageBox::Critical, tr( "zTree not found" ), QMessageBox messageBox{ QMessageBox::Critical, tr( "zTree not found" ),
tr( "No zTree installation found in '%1'. Running zTree will not be possible." ) tr( "No zTree installation found in '%1'. Running zTree will not be possible." )
.arg( *( *settingsItems )[ ( int )settingsItems_t::ZTREE_INSTALLATION_DIRECTORY ] ), QMessageBox::Ok }; .arg( *( *settingsItems )[ ( int )settItms_t::ZTREE_INST_DIR ] ), QMessageBox::Ok };
messageBox.exec(); messageBox.exec();
debugMessagesTextEdit->appendPlainText( tr( "[DEBUG] No zTree versions could be found in '%1'." ).arg( *( *settingsItems )[ ( int )settingsItems_t::ZTREE_INSTALLATION_DIRECTORY ] ) ); debugMessagesTextEdit->appendPlainText( tr( "[DEBUG] No zTree versions could be found in '%1'." ).arg( *( *settingsItems )[ ( int )settItms_t::ZTREE_INST_DIR ] ) );
} }
else { else {
InstalledZTreeVersions = new QStringList{ zTreeDirectory.entryList() }; InstalledZTreeVersions = new QStringList{ zTreeDirectory.entryList() };
@ -202,15 +201,15 @@ void lc::Lablib::ReadSettings() {
true, true, true, false, true, true, false, true, true, true, false, true }; true, true, true, false, true, true, false, true, true, true, false, true };
QString *tempItemStorage = nullptr; QString *tempItemStorage = nullptr;
for ( int i = 0; i < ( int )settingsItems_t::SETTINGS_ITEMS_QUANTITY; i++ ) { for ( int i = 0; i < ( int )settItms_t::SETT_ITMS_QUANT; i++ ) {
tempItemStorage = ReadSettingsItem( simpleLoadableItems[ i ], theItemsErrorComplaints[ i ], is_file[ i ] ); tempItemStorage = ReadSettingsItem( simpleLoadableItems[ i ], theItemsErrorComplaints[ i ], is_file[ i ] );
settingsItems->replace( i, tempItemStorage ); settingsItems->replace( i, tempItemStorage );
} }
tempItemStorage = nullptr; tempItemStorage = nullptr;
// Let the local zLeaf name default to 'local' if none was given in the settings // Let the local zLeaf name default to 'local' if none was given in the settings
if ( !( *settingsItems )[ ( int )settingsItems_t::LOCAL_ZLEAF_NAME ] ) { if ( !( *settingsItems )[ ( int )settItms_t::LOCAL_ZLEAF_NAME ] ) {
settingsItems->replace( ( int )settingsItems_t::LOCAL_ZLEAF_NAME, new QString{ tr( "local" ) } ); settingsItems->replace( ( int )settItms_t::LOCAL_ZLEAF_NAME, new QString{ tr( "local" ) } );
} }
// Read the list of users with administrative rights // Read the list of users with administrative rights
@ -414,10 +413,10 @@ void lc::Lablib::ShowOrsee() {
QProcess showOrseeProcess; QProcess showOrseeProcess;
QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
showOrseeProcess.setProcessEnvironment( env ); showOrseeProcess.setProcessEnvironment( env );
showOrseeProcess.startDetached( *( *settingsItems )[ ( int )settingsItems_t::ORSEE_COMMAND ] ); showOrseeProcess.startDetached( *( *settingsItems )[ ( int )settItms_t::ORSEE_COMMAND ] );
// Output message via the debug messages tab // Output message via the debug messages tab
debugMessagesTextEdit->appendPlainText( tr( "[DEBUG] %1" ).arg( *( *settingsItems )[ ( int )settingsItems_t::ORSEE_COMMAND ] ) ); debugMessagesTextEdit->appendPlainText( tr( "[DEBUG] %1" ).arg( *( *settingsItems )[ ( int )settItms_t::ORSEE_COMMAND ] ) );
} }
void lc::Lablib::ShowPreprints() { void lc::Lablib::ShowPreprints() {
@ -425,8 +424,8 @@ void lc::Lablib::ShowPreprints() {
QProcess showPreprintsProcess; QProcess showPreprintsProcess;
QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
showPreprintsProcess.setProcessEnvironment( env ); showPreprintsProcess.setProcessEnvironment( env );
QString program{ *( *settingsItems )[ ( int )settingsItems_t::FILE_MANAGER ] }; QString program{ *( *settingsItems )[ ( int )settItms_t::FILE_MANAGER ] };
QStringList arguments{ QStringList{} << *( *settingsItems )[ ( int )settingsItems_t::LABCONTROL_INSTALLATION_DIRECTORY ] + "/preprints" }; QStringList arguments{ QStringList{} << *( *settingsItems )[ ( int )settItms_t::LC_INST_DIR ] + "/preprints" };
showPreprintsProcess.startDetached( program, arguments ); showPreprintsProcess.startDetached( program, arguments );
// Output message via the debug messages tab // Output message via the debug messages tab
@ -469,7 +468,7 @@ void lc::Lablib::StartNewZTreeInstance() {
} }
void lc::Lablib::SetLocalZLeafDefaultName( const QString &argName ) { void lc::Lablib::SetLocalZLeafDefaultName( const QString &argName ) {
delete ( *settingsItems )[ ( int )settingsItems_t::LOCAL_ZLEAF_NAME ]; delete ( *settingsItems )[ ( int )settItms_t::LOCAL_ZLEAF_NAME ];
( *settingsItems )[ ( int )settingsItems_t::LOCAL_ZLEAF_NAME ] = new QString{ argName }; ( *settingsItems )[ ( int )settItms_t::LOCAL_ZLEAF_NAME ] = new QString{ argName };
labSettings.setValue( "local_zLeaf_name", argName ); labSettings.setValue( "local_zLeaf_name", argName );
} }

@ -91,7 +91,7 @@ public:
* *
* @return A pointer to the QString storing the default name for local zLeafs * @return A pointer to the QString storing the default name for local zLeafs
*/ */
QString *GetLocalZLeafDefaultName() const { return ( *settingsItems )[ ( int )settingsItems_t::LOCAL_ZLEAF_NAME ]; } QString *GetLocalZLeafDefaultName() const { return ( *settingsItems )[ ( int )settItms_t::LOCAL_ZLEAF_NAME ]; }
/** Returns a pointer to a QVector<unsigned int> containing all by sessions occupied ports /** Returns a pointer to a QVector<unsigned int> containing all by sessions occupied ports
* *
* @return A pointer to a QVector<unsigned int> containing all occupied ports * @return A pointer to a QVector<unsigned int> containing all occupied ports
@ -111,7 +111,7 @@ public:
* *
* @return A pointer to to a specified QString stored in 'settings_items' storing all command QString pointers * @return A pointer to to a specified QString stored in 'settings_items' storing all command QString pointers
*/ */
QString *GetSettingsItem( settingsItems_t argItem ) const { return ( *settingsItems )[ ( int )argItem ]; } QString *GetSettingsItem( settItms_t argItem ) const { return ( *settingsItems )[ ( int )argItem ]; }
/** Returns a pointer to the 'settingsItems' storing all command QString pointers /** Returns a pointer to the 'settingsItems' storing all command QString pointers
* *
* @return A pointer to the 'settingsItems' storing all command QString pointers * @return A pointer to the 'settingsItems' storing all command QString pointers

@ -273,10 +273,10 @@ QVector<QString> *lc::ReceiptsHandler::GetParticipantsDataFromPaymentFile() {
QString *lc::ReceiptsHandler::LoadLatexHeader() { QString *lc::ReceiptsHandler::LoadLatexHeader() {
// Prepare all facilities to read the latex header file // Prepare all facilities to read the latex header file
QFile latexHeaderFile( *( *settingsItems )[ ( int )settingsItems_t::LABCONTROL_INSTALLATION_DIRECTORY ] + "/" + *latexHeaderName + "_header.tex" ); QFile latexHeaderFile( *( *settingsItems )[ ( int )settItms_t::LC_INST_DIR ] + "/" + *latexHeaderName + "_header.tex" );
if ( !latexHeaderFile.open( QIODevice::ReadOnly | QIODevice::Text ) ) { if ( !latexHeaderFile.open( QIODevice::ReadOnly | QIODevice::Text ) ) {
QMessageBox messageBox{ QMessageBox::Critical, tr( "LaTeX header could not be loaded" ), tr( "The LaTeX header at '%1/%2_header.tex' could not be loaded. Receipts printing will not work." ) QMessageBox messageBox{ QMessageBox::Critical, tr( "LaTeX header could not be loaded" ), tr( "The LaTeX header at '%1/%2_header.tex' could not be loaded. Receipts printing will not work." )
.arg( *( *settingsItems )[ ( int )settingsItems_t::LABCONTROL_INSTALLATION_DIRECTORY ] ).arg( *latexHeaderName ), QMessageBox::Ok }; .arg( *( *settingsItems )[ ( int )settItms_t::LC_INST_DIR ] ).arg( *latexHeaderName ), QMessageBox::Ok };
messageBox.exec(); messageBox.exec();
return nullptr; return nullptr;
} }

@ -45,7 +45,7 @@ class ReceiptsPrinter : public QThread {
QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
process->setProcessEnvironment( env ); process->setProcessEnvironment( env );
process->setWorkingDirectory( *workpath ); process->setWorkingDirectory( *workpath );
process->start( *( *settingsItems )[ ( int )settingsItems_t::LATEX_COMMAND ], arguments ); process->start( *( *settingsItems )[ ( int )settItms_t::LATEX_CMD ], arguments );
if( !process->waitForFinished( processTimeOut ) ) { if( !process->waitForFinished( processTimeOut ) ) {
QMessageBox message_box{ QMessageBox::Warning, "dvi creation failed", "The creation of the receipts dvi timed out after 30 seconds. Automatic receipts creation will not work.", QMessageBox::Ok }; QMessageBox message_box{ QMessageBox::Warning, "dvi creation failed", "The creation of the receipts dvi timed out after 30 seconds. Automatic receipts creation will not work.", QMessageBox::Ok };
message_box.exec(); message_box.exec();
@ -63,7 +63,7 @@ class ReceiptsPrinter : public QThread {
process = new QProcess{}; process = new QProcess{};
process->setProcessEnvironment( env ); process->setProcessEnvironment( env );
process->setWorkingDirectory( *workpath ); process->setWorkingDirectory( *workpath );
process->start( *( *settingsItems )[ ( int )settingsItems_t::DVIPS_COMMAND ], arguments ); process->start( *( *settingsItems )[ ( int )settItms_t::DVIPS_CMD ], arguments );
if( !process->waitForFinished( processTimeOut ) ) { if( !process->waitForFinished( processTimeOut ) ) {
emit ErrorOccurred(new QString{ "The conversion of the receipts dvi to postscript timed out after 30 seconds. Automatic receipts creation will not work." }, new QString{ "dvi to postscript conversion failed" } ); emit ErrorOccurred(new QString{ "The conversion of the receipts dvi to postscript timed out after 30 seconds. Automatic receipts creation will not work." }, new QString{ "dvi to postscript conversion failed" } );
delete process; delete process;
@ -74,14 +74,14 @@ class ReceiptsPrinter : public QThread {
process = nullptr; process = nullptr;
// Print the postscript file // Print the postscript file
if ( ( *settingsItems )[ ( int )settingsItems_t::LPR_COMMAND ] ) { if ( ( *settingsItems )[ ( int )settItms_t::LPR_CMD ] ) {
arguments = QStringList{}; arguments = QStringList{};
arguments << QString{ *workpath + "/" + *dateString + ".ps" }; arguments << QString{ *workpath + "/" + *dateString + ".ps" };
process = new QProcess{}; process = new QProcess{};
process->setProcessEnvironment( env ); process->setProcessEnvironment( env );
process->setWorkingDirectory( *workpath ); process->setWorkingDirectory( *workpath );
process->start( *( *settingsItems )[ ( int )settingsItems_t::LPR_COMMAND ], arguments ); process->start( *( *settingsItems )[ ( int )settItms_t::LPR_CMD ], arguments );
if( !process->waitForFinished( processTimeOut ) ) { if( !process->waitForFinished( processTimeOut ) ) {
emit ErrorOccurred( new QString{ "The receipts postscript file was successfully created but could not be printed." }, new QString{ "Printing failed" } ); emit ErrorOccurred( new QString{ "The receipts postscript file was successfully created but could not be printed." }, new QString{ "Printing failed" } );
} }
@ -90,14 +90,14 @@ class ReceiptsPrinter : public QThread {
} }
// Convert the postscript file to pdf // Convert the postscript file to pdf
if ( ( *settingsItems )[ ( int )settingsItems_t::PS2PDF_COMMAND ] ) { if ( ( *settingsItems )[ ( int )settItms_t::PS2PDF_COMMAND ] ) {
arguments = QStringList{}; arguments = QStringList{};
arguments << QString{ *workpath + "/" + *dateString + ".ps" } << QString{ *workpath + "/" + *dateString + ".pdf" }; arguments << QString{ *workpath + "/" + *dateString + ".ps" } << QString{ *workpath + "/" + *dateString + ".pdf" };
process = new QProcess{}; process = new QProcess{};
process->setProcessEnvironment( env ); process->setProcessEnvironment( env );
process->setWorkingDirectory( *workpath ); process->setWorkingDirectory( *workpath );
process->start( *( *settingsItems )[ ( int )settingsItems_t::PS2PDF_COMMAND ], arguments ); process->start( *( *settingsItems )[ ( int )settItms_t::PS2PDF_COMMAND ], arguments );
if( !process->waitForFinished( processTimeOut ) ) { if( !process->waitForFinished( processTimeOut ) ) {
emit ErrorOccurred( new QString{ "The receipts were successfully printed but the creation of the PDF file failed." }, new QString{ "PDF creation failed" } ); emit ErrorOccurred( new QString{ "The receipts were successfully printed but the creation of the PDF file failed." }, new QString{ "PDF creation failed" } );
} }
@ -105,21 +105,21 @@ class ReceiptsPrinter : public QThread {
process = nullptr; process = nullptr;
// Show the postscript file if the conversion succeeded // Show the postscript file if the conversion succeeded
if ( ( *settingsItems )[ ( int )settingsItems_t::POSTSCRIPT_VIEWER ] ) { if ( ( *settingsItems )[ ( int )settItms_t::POSTSCRIPT_VIEWER ] ) {
arguments = QStringList{}; arguments = QStringList{};
arguments << QString{ *workpath + "/" + *dateString + ".ps" }; arguments << QString{ *workpath + "/" + *dateString + ".ps" };
process = new QProcess{}; process = new QProcess{};
process->setProcessEnvironment( env ); process->setProcessEnvironment( env );
process->setWorkingDirectory( *workpath ); process->setWorkingDirectory( *workpath );
process->startDetached( *( *settingsItems )[ ( int )settingsItems_t::POSTSCRIPT_VIEWER ], arguments ); process->startDetached( *( *settingsItems )[ ( int )settItms_t::POSTSCRIPT_VIEWER ], arguments );
delete process; delete process;
process = nullptr; process = nullptr;
} }
} }
// Clean up the zTree working path // Clean up the zTree working path
if ( ( *settingsItems )[ ( int )settingsItems_t::RM_COMMAND ] ) { if ( ( *settingsItems )[ ( int )settItms_t::RM_CMD ] ) {
arguments = QStringList{}; arguments = QStringList{};
arguments << QString{ *workpath + "/" + *dateString + ".aux" } arguments << QString{ *workpath + "/" + *dateString + ".aux" }
<< QString{ *workpath + "/" + *dateString + ".dvi" } << QString{ *workpath + "/" + *dateString + ".dvi" }
@ -129,7 +129,7 @@ class ReceiptsPrinter : public QThread {
process = new QProcess{}; process = new QProcess{};
process->setProcessEnvironment( env ); process->setProcessEnvironment( env );
process->setWorkingDirectory( *workpath ); process->setWorkingDirectory( *workpath );
process->start( *( *settingsItems )[ ( int )settingsItems_t::RM_COMMAND ], arguments); process->start( *( *settingsItems )[ ( int )settItms_t::RM_CMD ], arguments);
if( !process->waitForFinished( processTimeOut ) ) { if( !process->waitForFinished( processTimeOut ) ) {
emit ErrorOccurred(new QString("The cleanup of the temporary files for receipts creation timed out. Some spare files may be left in your zTree working directory."), new QString("Cleanup failed")); emit ErrorOccurred(new QString("The cleanup of the temporary files for receipts creation timed out. Some spare files may be left in your zTree working directory."), new QString("Cleanup failed"));
} }

@ -45,7 +45,7 @@ lc::Session::Session( QPlainTextEdit * const argDebugMessagesTextEdit,
InitializeClasses(); InitializeClasses();
} }
if ( ( *settingsItems )[ ( int )settingsItems_t::WMCTRL_COMMAND ] ) { if ( ( *settingsItems )[ ( int )settItms_t::WMCTRL_CMD ] ) {
QTimer::singleShot( 5000, this, SLOT( RenameWindow() ) ); QTimer::singleShot( 5000, this, SLOT( RenameWindow() ) );
} }
} }
@ -79,7 +79,7 @@ void lc::Session::InitializeClasses() {
zTreeInstance = new ZTree{ debugMessagesTextEdit, zTreeDataTargetPath, zTreeInstance = new ZTree{ debugMessagesTextEdit, zTreeDataTargetPath,
zTreePort, zTreeVersionPath, settingsItems }; zTreePort, zTreeVersionPath, settingsItems };
// Only create a 'Receipts_Handler' instance, if all neccessary variables were set // Only create a 'Receipts_Handler' instance, if all neccessary variables were set
if ( latexHeaderName != "None found" && ( *settingsItems )[ ( int )settingsItems_t::DVIPS_COMMAND ] && ( *settingsItems )[ ( int )settingsItems_t::LATEX_COMMAND ] ) { if ( latexHeaderName != "None found" && ( *settingsItems )[ ( int )settItms_t::DVIPS_CMD ] && ( *settingsItems )[ ( int )settItms_t::LATEX_CMD ] ) {
receiptsHandler = new ReceiptsHandler{ debugMessagesTextEdit, zTreeDataTargetPath, receiptsHandler = new ReceiptsHandler{ debugMessagesTextEdit, zTreeDataTargetPath,
printReceiptsForLocalClients, printReceiptsForLocalClients,
anonymousReceiptsPlaceholder, anonymousReceiptsPlaceholder,
@ -99,7 +99,7 @@ void lc::Session::RenameWindow() {
QProcess renameZTreeWindowProcess; QProcess renameZTreeWindowProcess;
QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
renameZTreeWindowProcess.setProcessEnvironment( env ); renameZTreeWindowProcess.setProcessEnvironment( env );
renameZTreeWindowProcess.startDetached( *( *settingsItems )[ ( int )settingsItems_t::WMCTRL_COMMAND ], arguments ); renameZTreeWindowProcess.startDetached( *( *settingsItems )[ ( int )settItms_t::WMCTRL_CMD ], arguments );
debugMessagesTextEdit->appendPlainText( "[DEBUG] Renamed window" ); debugMessagesTextEdit->appendPlainText( "[DEBUG] Renamed window" );

@ -23,9 +23,9 @@ lc::ZTree::ZTree( QPlainTextEdit *argDebugMessagesTextEdit,
const QString &argZTreeDataTargetPath, const int &argZTreePort, const QString &argZTreeDataTargetPath, const int &argZTreePort,
const QString &argZTreeVersionPath, const QString &argZTreeVersionPath,
const QVector<QString*> * const argSettingsItems ) { const QVector<QString*> * const argSettingsItems ) {
QString program{ *( *argSettingsItems )[ ( int )settingsItems_t::LABCONTROL_INSTALLATION_DIRECTORY ] + "/scripts/start_zTree_labcontrol2.sh" }; QString program{ *( *argSettingsItems )[ ( int )settItms_t::LC_INST_DIR ] + "/scripts/start_zTree_labcontrol2.sh" };
QStringList arguments; QStringList arguments;
arguments << *( *argSettingsItems )[ ( int )settingsItems_t::ZTREE_INSTALLATION_DIRECTORY ] << argZTreeVersionPath << argZTreeDataTargetPath << QString::number( static_cast<int>( argZTreePort ) - 7000 ); arguments << *( *argSettingsItems )[ ( int )settItms_t::ZTREE_INST_DIR ] << argZTreeVersionPath << argZTreeDataTargetPath << QString::number( static_cast<int>( argZTreePort ) - 7000 );
QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
zTreeInstance.setProcessEnvironment( env ); zTreeInstance.setProcessEnvironment( env );

@ -49,30 +49,35 @@ lc::MainWindow::~MainWindow() {
bool lc::MainWindow::CheckIfUserIsAdmin() { bool lc::MainWindow::CheckIfUserIsAdmin() {
// Query the current user's name or give an error if this fails // Query the current user's name or give an error if this fails
QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
QString userName{ "" }; QString userName;
// For Linux // For Linux
if ( env.contains( "USER" )) { if ( env.contains( "USER" ) ) {
userName = env.value( "USER", "" ); userName = env.value( "USER", "" );
} } else if ( env.contains( "USERNAME" ) ) { // For Windows
// For Windows
if ( env.contains( "USERNAME" )) {
userName = env.value( "USERNAME", "" ); userName = env.value( "USERNAME", "" );
} }
if ( userName == "" ) { if ( userName == "" ) {
QMessageBox messageBox{ QMessageBox::Warning, tr( "User not detectable" ), QMessageBox messageBox{ QMessageBox::Warning, tr( "User not detectable" ),
tr( "Your user name could not be queryed. The admin tab will be disabled. You won't be able to perform administrative actions but can conduct experiments normally." ), QMessageBox::Ok }; tr( "Your user name could not be queryed. The admin tab will be"
" disabled. You won't be able to perform administrative"
" actions but can conduct experiments normally." ),
QMessageBox::Ok };
messageBox.exec(); messageBox.exec();
return false; return false;
} }
ui->PTEDebugMessages->appendPlainText( tr( "[DEBUG] The user's name is %1." ).arg( userName ) );
ui->PTEDebugMessages->appendPlainText( tr( "[DEBUG] The user's name is %1." )
.arg( userName ) );
lablib->SetUserNameOnServer( userName ); lablib->SetUserNameOnServer( userName );
QStringList *adminUsers = lablib->GetAdminUsers(); QStringList *adminUsers = lablib->GetAdminUsers();
if ( !( adminUsers == nullptr ) ) { if ( adminUsers != nullptr ) {
for ( auto s : *adminUsers ) { for ( auto s : *adminUsers ) {
if ( s == userName ) { if ( s == userName ) {
ui->PTEDebugMessages->appendPlainText( tr( "[DEBUG] '%1' has administrative rights." ).arg( userName ) ); ui->PTEDebugMessages->appendPlainText( tr( "[DEBUG] '%1' has administrative"
" rights." ).arg( userName ) );
return true; return true;
} }
} }
@ -83,7 +88,7 @@ bool lc::MainWindow::CheckIfUserIsAdmin() {
void lc::MainWindow::DisableDisfunctionalWidgets() { void lc::MainWindow::DisableDisfunctionalWidgets() {
// Disable all functions relying on the labcontrol installation directory if it is not available // Disable all functions relying on the labcontrol installation directory if it is not available
if ( !lablib->GetSettingsItem( settingsItems_t::LABCONTROL_INSTALLATION_DIRECTORY ) ) { if ( !lablib->GetSettingsItem( settItms_t::LC_INST_DIR ) ) {
ui->CBClientNames->setEnabled( false ); ui->CBClientNames->setEnabled( false );
ui->CBWebcamChooser->setEnabled( false ); ui->CBWebcamChooser->setEnabled( false );
ui->GBClientActions->setEnabled( false ); ui->GBClientActions->setEnabled( false );
@ -100,22 +105,23 @@ void lc::MainWindow::DisableDisfunctionalWidgets() {
} }
// Disable 'PBShowPreprints', if 'file_manager' was not set // Disable 'PBShowPreprints', if 'file_manager' was not set
if ( !lablib->GetSettingsItem( settingsItems_t::FILE_MANAGER ) ) { if ( !lablib->GetSettingsItem( settItms_t::FILE_MANAGER ) ) {
ui->PBShowPreprints->setEnabled( false ); ui->PBShowPreprints->setEnabled( false );
} }
// Disable 'PBBoot', if 'network_broadcast_address' was not set // Disable 'PBBoot', if 'network_broadcast_address' was not set
if ( !lablib->GetSettingsItem( settingsItems_t::NETWORK_BROADCAST_ADDRESS ) ) { if ( !lablib->GetSettingsItem( settItms_t::NETW_BRDCAST_ADDR ) ) {
ui->PBBoot->setEnabled( false ); ui->PBBoot->setEnabled( false );
} }
// Disable 'PBShowORSEE', if 'orsee_command' was not set // Disable 'PBShowORSEE', if 'orsee_command' was not set
if ( !lablib->GetSettingsItem( settingsItems_t::ORSEE_COMMAND ) ) { if ( !lablib->GetSettingsItem( settItms_t::ORSEE_COMMAND ) ) {
ui->PBShowORSEE->setEnabled( false ); ui->PBShowORSEE->setEnabled( false );
} }
// Disable all widgets needless if 'public_key_path_user' or 'user_name_on_clients' was not set // Disable all widgets needless if 'public_key_path_user' or 'user_name_on_clients' was not set
if ( !lablib->GetSettingsItem( settingsItems_t::PUBLICKEY_PATH_USER ) || !lablib->GetSettingsItem( settingsItems_t::USER_NAME_ON_CLIENTS ) ) { if ( !lablib->GetSettingsItem( settItms_t::SSH_KEY_USER )
|| !lablib->GetSettingsItem( settItms_t::USER_NAME_ON_CLIENTS ) ) {
ui->CBClientNames->setEnabled( false ); ui->CBClientNames->setEnabled( false );
ui->LEFilePath->setEnabled( false ); ui->LEFilePath->setEnabled( false );
ui->LFakeName->setEnabled( false ); ui->LFakeName->setEnabled( false );
@ -131,32 +137,33 @@ void lc::MainWindow::DisableDisfunctionalWidgets() {
} }
// Disable widgets needless if 'public_key_path_root' was not set // Disable widgets needless if 'public_key_path_root' was not set
if ( !lablib->GetSettingsItem( settingsItems_t::PUBLICKEY_PATH_ROOT ) ) { if ( !lablib->GetSettingsItem( settItms_t::SSH_KEY_ROOT ) ) {
ui->RBUseUserRoot->setEnabled( false ); ui->RBUseUserRoot->setEnabled( false );
ui->RBUseLocalUser->click(); ui->RBUseLocalUser->click();
} }
if ( !lablib->GetSettingsItem( settingsItems_t::PUBLICKEY_PATH_ROOT ) && !lablib->GetSettingsItem( settingsItems_t::PUBLICKEY_PATH_USER ) ) { if ( !lablib->GetSettingsItem( settItms_t::SSH_KEY_ROOT )
&& !lablib->GetSettingsItem( settItms_t::SSH_KEY_USER ) ) {
ui->GBExecuteOnEveryClient->setEnabled( false ); ui->GBExecuteOnEveryClient->setEnabled( false );
ui->GBOptionsForAdminActions->setEnabled( false ); ui->GBOptionsForAdminActions->setEnabled( false );
ui->PBOpenTerminal->setEnabled( false ); ui->PBOpenTerminal->setEnabled( false );
} }
// Disable beam functionality if 'rcp_command' was not set // Disable beam functionality if 'rcp_command' was not set
if ( !lablib->GetSettingsItem( settingsItems_t::RCP_COMMAND ) ) { if ( !lablib->GetSettingsItem( settItms_t::RCP_CMD ) ) {
ui->LEFilePath->setEnabled( false ); ui->LEFilePath->setEnabled( false );
ui->PBBeamFile->setEnabled( false ); ui->PBBeamFile->setEnabled( false );
ui->PBChooseFile->setEnabled( false ); ui->PBChooseFile->setEnabled( false );
} }
// Disable 'PBRunzLeaf' and 'PBStartzLeaf' if 'server_ip' was not set // Disable 'PBRunzLeaf' and 'PBStartzLeaf' if 'server_ip' was not set
if ( !lablib->GetSettingsItem( settingsItems_t::SERVER_IP ) ) { if ( !lablib->GetSettingsItem( settItms_t::SERVER_IP ) ) {
ui->PBRunzLeaf->setEnabled( false ); ui->PBRunzLeaf->setEnabled( false );
ui->PBStartzLeaf->setEnabled( false ); ui->PBStartzLeaf->setEnabled( false );
} }
// Disable any actions concerning the clients if 'ssh_command' was not set // Disable any actions concerning the clients if 'ssh_command' was not set
if ( !lablib->GetSettingsItem( settingsItems_t::SSH_COMMAND ) ) { if ( !lablib->GetSettingsItem( settItms_t::SSH_CMD ) ) {
ui->CBClientNames->setEnabled( false ); ui->CBClientNames->setEnabled( false );
ui->GBClientActions->setEnabled( false ); ui->GBClientActions->setEnabled( false );
ui->LFakeName->setEnabled( false ); ui->LFakeName->setEnabled( false );
@ -171,29 +178,29 @@ void lc::MainWindow::DisableDisfunctionalWidgets() {
} }
// Disable 'PBOpenTerminal' if 'terminal_emulator_command' was not set // Disable 'PBOpenTerminal' if 'terminal_emulator_command' was not set
if ( !lablib->GetSettingsItem( settingsItems_t::TERMINAL_EMULATOR_COMMAND ) ) { if ( !lablib->GetSettingsItem( settItms_t::TERM_EMUL_CMD ) ) {
ui->GBExecuteOnEveryClient->setEnabled( false ); ui->GBExecuteOnEveryClient->setEnabled( false );
ui->PBOpenTerminal->setEnabled( false ); ui->PBOpenTerminal->setEnabled( false );
} }
// Disable 'PBViewDesktop' if 'vnc_viewer' was not set // Disable 'PBViewDesktop' if 'vnc_viewer' was not set
if ( !lablib->GetSettingsItem( settingsItems_t::VNC_VIEWER ) ) { if ( !lablib->GetSettingsItem( settItms_t::VNC_VIEWER ) ) {
ui->PBViewDesktop->setEnabled( false ); ui->PBViewDesktop->setEnabled( false );
} }
// Disable 'PBBoot' if 'wakeonlan_command' was not set // Disable 'PBBoot' if 'wakeonlan_command' was not set
if ( !lablib->GetSettingsItem( settingsItems_t::WAKEONLAN_COMMAND ) ) { if ( !lablib->GetSettingsItem( settItms_t::WAKEONLAN_CMD ) ) {
ui->PBBoot->setEnabled( false ); ui->PBBoot->setEnabled( false );
} }
// Disable the disable screensaver function if the 'xset_command' was not set // Disable the disable screensaver function if the 'xset_command' was not set
if ( !lablib->GetSettingsItem( settingsItems_t::XSET_COMMAND ) ) { if ( !lablib->GetSettingsItem( settItms_t::XSET_CMD ) ) {
ui->PBDeactivateScreensaver->setEnabled( false ); ui->PBDeactivateScreensaver->setEnabled( false );
} }
} }
void lc::MainWindow::LoadIconPixmaps() { void lc::MainWindow::LoadIconPixmaps() {
if ( !lablib->GetSettingsItem( settingsItems_t::LABCONTROL_INSTALLATION_DIRECTORY ) ) { if ( !lablib->GetSettingsItem( settItms_t::LC_INST_DIR ) ) {
return; return;
} }
@ -206,17 +213,17 @@ void lc::MainWindow::LoadIconPixmaps() {
<< "zLeaf.png" }; << "zLeaf.png" };
for ( int i = 0; i < ( int )icons_t::ICON_QUANTITY; i++ ) { for ( int i = 0; i < ( int )icons_t::ICON_QUANTITY; i++ ) {
if ( !icons[ i ].load( *lablib->GetSettingsItem( settingsItems_t::LABCONTROL_INSTALLATION_DIRECTORY ) + "/icons/" + iconNames[ i ] ) ) { if ( !icons[ i ].load( *lablib->GetSettingsItem( settItms_t::LC_INST_DIR ) + "/icons/" + iconNames[ i ] ) ) {
QMessageBox::information( this, tr( "Could not load icon '%1'" ).arg( iconNames[ i ] ), QMessageBox::information( this, tr( "Could not load icon '%1'" ).arg( iconNames[ i ] ),
tr( "The icon in '%1/icons/%2' could not be loaded." ) tr( "The icon in '%1/icons/%2' could not be loaded." )
.arg( *lablib->GetSettingsItem( settingsItems_t::LABCONTROL_INSTALLATION_DIRECTORY ) ).arg( iconNames[ i ] ), QMessageBox::Ok ); .arg( *lablib->GetSettingsItem( settItms_t::LC_INST_DIR ) ).arg( iconNames[ i ] ), QMessageBox::Ok );
} }
} }
} }
void lc::MainWindow::on_CBWebcamChooser_activated( int index ) { void lc::MainWindow::on_CBWebcamChooser_activated( int argIndex ) {
if ( !( index == 0 ) ) { if ( argIndex != 0 ) {
QString program{ *lablib->GetSettingsItem( settingsItems_t::LABCONTROL_INSTALLATION_DIRECTORY ) + "/webcam_display" }; QString program{ *lablib->GetSettingsItem( settItms_t::LC_INST_DIR ) + "/webcam_display" };
QStringList arguments; QStringList arguments;
arguments << ui->CBWebcamChooser->currentText(); arguments << ui->CBWebcamChooser->currentText();
@ -229,7 +236,8 @@ void lc::MainWindow::on_CBWebcamChooser_activated( int index ) {
void lc::MainWindow::on_PBBeamFile_clicked() { void lc::MainWindow::on_PBBeamFile_clicked() {
QModelIndexList activatedItems = ui->TVClients->selectionModel()->selectedIndexes(); QModelIndexList activatedItems = ui->TVClients->selectionModel()->selectedIndexes();
const QString * const publickeyPathUser = lablib->GetSettingsItem( settingsItems_t::PUBLICKEY_PATH_USER ), * const userNameOnClients = lablib->GetSettingsItem( settingsItems_t::USER_NAME_ON_CLIENTS ); const QString * const publickeyPathUser{ lablib->GetSettingsItem( settItms_t::SSH_KEY_USER ) };
const QString * const userNameOnClients{ lablib->GetSettingsItem( settItms_t::USER_NAME_ON_CLIENTS ) };
const QString fileToBeam{ ui->LEFilePath->text() }; const QString fileToBeam{ ui->LEFilePath->text() };
for ( QModelIndexList::ConstIterator it = activatedItems.cbegin(); it != activatedItems.cend(); ++it ) { for ( QModelIndexList::ConstIterator it = activatedItems.cbegin(); it != activatedItems.cend(); ++it ) {
if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) { if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) {
@ -244,7 +252,7 @@ void lc::MainWindow::on_PBBoot_clicked() {
for ( QModelIndexList::ConstIterator it = activatedItems.cbegin(); it != activatedItems.cend(); ++it ) { for ( QModelIndexList::ConstIterator it = activatedItems.cbegin(); it != activatedItems.cend(); ++it ) {
if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) { if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) {
Client *client = static_cast< Client* >( ( *it ).data( Qt::UserRole ).value< void * >() ); Client *client = static_cast< Client* >( ( *it ).data( Qt::UserRole ).value< void * >() );
client->Boot( lablib->GetSettingsItem( settingsItems_t::NETWORK_BROADCAST_ADDRESS ) ); client->Boot( lablib->GetSettingsItem( settItms_t::NETW_BRDCAST_ADDR ) );
} }
} }
} }
@ -268,7 +276,8 @@ void lc::MainWindow::on_PBChooseFile_clicked() {
} }
void lc::MainWindow::on_PBDeactivateScreensaver_clicked() { void lc::MainWindow::on_PBDeactivateScreensaver_clicked() {
const QString * const publickey_path_user = lablib->GetSettingsItem( settingsItems_t::PUBLICKEY_PATH_USER ), * const user_name_on_clients = lablib->GetSettingsItem( settingsItems_t::USER_NAME_ON_CLIENTS ); const QString * const publickey_path_user{ lablib->GetSettingsItem( settItms_t::SSH_KEY_USER ) };
const QString * const user_name_on_clients{ lablib->GetSettingsItem( settItms_t::USER_NAME_ON_CLIENTS ) };
QVector< Client* > *clients = lablib->GetClients(); QVector< Client* > *clients = lablib->GetClients();
for ( auto s : *clients ) { for ( auto s : *clients ) {
if ( s->GetClientState() >= state_t::RESPONDING ) if ( s->GetClientState() >= state_t::RESPONDING )
@ -306,9 +315,9 @@ void lc::MainWindow::on_PBExecute_clicked() {
// Set the correct public key // Set the correct public key
QString *tempPublickeyPathUser = nullptr; QString *tempPublickeyPathUser = nullptr;
if ( ui->RBUseUserRoot->isChecked() ) { if ( ui->RBUseUserRoot->isChecked() ) {
tempPublickeyPathUser = lablib->GetSettingsItem( settingsItems_t::PUBLICKEY_PATH_ROOT ); tempPublickeyPathUser = lablib->GetSettingsItem( settItms_t::SSH_KEY_ROOT );
} else { } else {
tempPublickeyPathUser = lablib->GetSettingsItem( settingsItems_t::PUBLICKEY_PATH_USER ); tempPublickeyPathUser = lablib->GetSettingsItem( settItms_t::SSH_KEY_USER );
} }
const QString * const publickeyPathUser = tempPublickeyPathUser; const QString * const publickeyPathUser = tempPublickeyPathUser;
@ -317,7 +326,8 @@ void lc::MainWindow::on_PBExecute_clicked() {
ui->PTEDebugMessages->appendPlainText( tr( "[DEBUG] Executing command '%1' on every client." ).arg( command ) ); ui->PTEDebugMessages->appendPlainText( tr( "[DEBUG] Executing command '%1' on every client." ).arg( command ) );
for ( auto s: *clients ) { for ( auto s: *clients ) {
if ( !( s->name.contains( "backup", Qt::CaseInsensitive ) ) ) { if ( !( s->name.contains( "backup", Qt::CaseInsensitive ) ) ) {
s->OpenTerminal( command, ui->RBUseUserRoot->isChecked(), publickeyPathUser, lablib->GetSettingsItem( settingsItems_t::USER_NAME_ON_CLIENTS ) ); s->OpenTerminal( command, ui->RBUseUserRoot->isChecked(), publickeyPathUser,
lablib->GetSettingsItem( settItms_t::USER_NAME_ON_CLIENTS ) );
} }
} }
} else { } else {
@ -326,7 +336,8 @@ void lc::MainWindow::on_PBExecute_clicked() {
for ( QModelIndexList::ConstIterator it = activated_items.cbegin(); it != activated_items.cend(); ++it ) { for ( QModelIndexList::ConstIterator it = activated_items.cbegin(); it != activated_items.cend(); ++it ) {
if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) { if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) {
Client *client = static_cast< Client* >( ( *it ).data( Qt::UserRole ).value< void * >() ); Client *client = static_cast< Client* >( ( *it ).data( Qt::UserRole ).value< void * >() );
client->OpenTerminal( command, ui->RBUseUserRoot->isChecked(), publickeyPathUser, lablib->GetSettingsItem( settingsItems_t::USER_NAME_ON_CLIENTS ) ); client->OpenTerminal( command, ui->RBUseUserRoot->isChecked(), publickeyPathUser,
lablib->GetSettingsItem( settItms_t::USER_NAME_ON_CLIENTS ) );
} }
} }
} }
@ -335,7 +346,7 @@ void lc::MainWindow::on_PBExecute_clicked() {
} }
void lc::MainWindow::on_PBKillLocalzLeaf_clicked() { void lc::MainWindow::on_PBKillLocalzLeaf_clicked() {
QString program{ *lablib->GetSettingsItem( settingsItems_t::LABCONTROL_INSTALLATION_DIRECTORY ) + "/scripts/kill_zLeaf_labcontrol2.sh" }; QString program{ *lablib->GetSettingsItem( settItms_t::LC_INST_DIR ) + "/scripts/kill_zLeaf_labcontrol2.sh" };
// Start the process // Start the process
QProcess kill_zleaf_process; QProcess kill_zleaf_process;
@ -351,7 +362,8 @@ void lc::MainWindow::on_PBKillLocalzLeaf_clicked() {
void lc::MainWindow::on_PBKillzLeaf_clicked() { void lc::MainWindow::on_PBKillzLeaf_clicked() {
QModelIndexList activated_items = ui->TVClients->selectionModel()->selectedIndexes(); QModelIndexList activated_items = ui->TVClients->selectionModel()->selectedIndexes();
const QString * const publickeyPathUser = lablib->GetSettingsItem( settingsItems_t::PUBLICKEY_PATH_USER ), * const userNameOnClients = lablib->GetSettingsItem( settingsItems_t::USER_NAME_ON_CLIENTS ); const QString * const publickeyPathUser{ lablib->GetSettingsItem( settItms_t::SSH_KEY_USER ) };
const QString * const userNameOnClients{ lablib->GetSettingsItem( settItms_t::USER_NAME_ON_CLIENTS ) };
for ( QModelIndexList::ConstIterator it = activated_items.cbegin(); it != activated_items.cend(); ++it ) { for ( QModelIndexList::ConstIterator it = activated_items.cbegin(); it != activated_items.cend(); ++it ) {
if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) { if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) {
Client *client = static_cast< Client* >( ( *it ).data( Qt::UserRole ).value< void * >() ); Client *client = static_cast< Client* >( ( *it ).data( Qt::UserRole ).value< void * >() );
@ -366,7 +378,7 @@ void lc::MainWindow::on_PBOpenFilesystem_clicked() {
if ( ui->RBUseUserRoot->isChecked() ) { if ( ui->RBUseUserRoot->isChecked() ) {
userToBeUsed = new QString{ "root" }; userToBeUsed = new QString{ "root" };
} else { } else {
userToBeUsed = new QString{ *lablib->GetSettingsItem( settingsItems_t::USER_NAME_ON_CLIENTS ) }; userToBeUsed = new QString{ *lablib->GetSettingsItem( settItms_t::USER_NAME_ON_CLIENTS ) };
} }
QModelIndexList activated_items = ui->TVClients->selectionModel()->selectedIndexes(); QModelIndexList activated_items = ui->TVClients->selectionModel()->selectedIndexes();
@ -382,17 +394,18 @@ void lc::MainWindow::on_PBOpenFilesystem_clicked() {
void lc::MainWindow::on_PBOpenTerminal_clicked() { void lc::MainWindow::on_PBOpenTerminal_clicked() {
QString *tempPublickeyPathUser = nullptr; QString *tempPublickeyPathUser = nullptr;
if ( ui->RBUseUserRoot->isChecked() ) { if ( ui->RBUseUserRoot->isChecked() ) {
tempPublickeyPathUser = lablib->GetSettingsItem( settingsItems_t::PUBLICKEY_PATH_ROOT ); tempPublickeyPathUser = lablib->GetSettingsItem( settItms_t::SSH_KEY_ROOT );
} else { } else {
tempPublickeyPathUser = lablib->GetSettingsItem( settingsItems_t::PUBLICKEY_PATH_USER ); tempPublickeyPathUser = lablib->GetSettingsItem( settItms_t::SSH_KEY_USER );
} }
const QString * const publickeyPathUser = tempPublickeyPathUser, const QString * const publickeyPathUser{ tempPublickeyPathUser };
* const userNameOnClients = lablib->GetSettingsItem( settingsItems_t::USER_NAME_ON_CLIENTS ); const QString * const userNameOnClients{ lablib->GetSettingsItem( settItms_t::USER_NAME_ON_CLIENTS ) };
QModelIndexList activated_items = ui->TVClients->selectionModel()->selectedIndexes(); QModelIndexList activated_items = ui->TVClients->selectionModel()->selectedIndexes();
for ( QModelIndexList::ConstIterator it = activated_items.cbegin(); it != activated_items.cend(); ++it ) { for ( QModelIndexList::ConstIterator it = activated_items.cbegin(); it != activated_items.cend(); ++it ) {
if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) { if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) {
Client *client = static_cast< Client* >( ( *it ).data( Qt::UserRole ).value< void * >() ); Client *client = static_cast< Client* >( ( *it ).data( Qt::UserRole ).value< void * >() );
client->OpenTerminal( QString{}, ui->RBUseUserRoot->isChecked(), publickeyPathUser, userNameOnClients ); client->OpenTerminal( QString{}, ui->RBUseUserRoot->isChecked(),
publickeyPathUser, userNameOnClients );
} }
} }
} }
@ -404,7 +417,8 @@ void lc::MainWindow::on_PBPrintPaymentFileManually_clicked() {
fileDialog->setOption( QFileDialog::ReadOnly, true ); fileDialog->setOption( QFileDialog::ReadOnly, true );
if( fileDialog->exec() ) { if( fileDialog->exec() ) {
QString fileName = fileDialog->selectedFiles().at( 0 ); QString fileName = fileDialog->selectedFiles().at( 0 );
QString *dateString = new QString{ fileName.split( '/', QString::KeepEmptyParts, Qt::CaseInsensitive ).last() QString *dateString = new QString{ fileName.split( '/', QString::KeepEmptyParts,
Qt::CaseInsensitive ).last()
.split( '.', QString::KeepEmptyParts, Qt::CaseInsensitive ).first() }; .split( '.', QString::KeepEmptyParts, Qt::CaseInsensitive ).first() };
QString *workPath = new QString{ fileName }; QString *workPath = new QString{ fileName };
workPath->truncate( workPath->lastIndexOf( '/' ) ); workPath->truncate( workPath->lastIndexOf( '/' ) );
@ -419,7 +433,9 @@ void lc::MainWindow::on_PBPrintPaymentFileManually_clicked() {
void lc::MainWindow::on_PBRunzLeaf_clicked() { void lc::MainWindow::on_PBRunzLeaf_clicked() {
// Show an error message, if no zTree version was chosen yet // Show an error message, if no zTree version was chosen yet
if ( ui->CBzLeafVersion->currentIndex() == 0 ) { if ( ui->CBzLeafVersion->currentIndex() == 0 ) {
QMessageBox messageBox{ QMessageBox::Warning, tr( "Unset z-Leaf version" ), tr( "There is no z-Leaf version chosen yet. Please choose one." ), QMessageBox::Ok, this }; QMessageBox messageBox{ QMessageBox::Warning, tr( "Unset z-Leaf version" ),
tr( "There is no z-Leaf version chosen yet. Please choose one." ),
QMessageBox::Ok, this };
messageBox.exec(); messageBox.exec();
return; return;
} }
@ -438,12 +454,13 @@ void lc::MainWindow::on_PBRunzLeaf_clicked() {
messageBox.exec(); messageBox.exec();
} else { } else {
const QString * const fakeName = new QString{ ui->CBClientNames->currentText() }, * const zLeafVersion = new QString{ ui->CBzLeafVersion->currentText() }, const QString * const fakeName = new QString{ ui->CBClientNames->currentText() }, * const zLeafVersion = new QString{ ui->CBzLeafVersion->currentText() },
* const publickeyPathUser = lablib->GetSettingsItem( settingsItems_t::PUBLICKEY_PATH_USER ), * const serverIP = lablib->GetSettingsItem( settingsItems_t::SERVER_IP ), * const publickeyPathUser = lablib->GetSettingsItem( settItms_t::SSH_KEY_USER ), * const serverIP = lablib->GetSettingsItem( settItms_t::SERVER_IP ),
* const userNameOnClients = lablib->GetSettingsItem( settingsItems_t::USER_NAME_ON_CLIENTS ); * const userNameOnClients = lablib->GetSettingsItem( settItms_t::USER_NAME_ON_CLIENTS );
for ( QModelIndexList::ConstIterator it = activatedItems.cbegin(); it != activatedItems.cend(); ++it ) { for ( QModelIndexList::ConstIterator it = activatedItems.cbegin(); it != activatedItems.cend(); ++it ) {
if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) { if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) {
Client *client = static_cast< Client* >( ( *it ).data( Qt::UserRole ).value< void * >() ); Client *client = static_cast< Client* >( ( *it ).data( Qt::UserRole ).value< void * >() );
client->StartZLeaf( publickeyPathUser, userNameOnClients, zLeafVersion, serverIP, ui->SBzLeafPort->value(), fakeName ); client->StartZLeaf( publickeyPathUser, userNameOnClients, zLeafVersion, serverIP,
ui->SBzLeafPort->value(), fakeName );
} }
} }
delete fakeName; delete fakeName;
@ -469,8 +486,8 @@ void lc::MainWindow::on_PBShowSessions_clicked() {
void lc::MainWindow::on_PBShutdown_clicked() { void lc::MainWindow::on_PBShutdown_clicked() {
QModelIndexList activatedItems = ui->TVClients->selectionModel()->selectedIndexes(); QModelIndexList activatedItems = ui->TVClients->selectionModel()->selectedIndexes();
const QString * const publickeyPathUser = lablib->GetSettingsItem( settingsItems_t::PUBLICKEY_PATH_USER ), const QString * const publickeyPathUser = lablib->GetSettingsItem( settItms_t::SSH_KEY_USER ),
* const userNameOnClients = lablib->GetSettingsItem( settingsItems_t::USER_NAME_ON_CLIENTS ); * const userNameOnClients = lablib->GetSettingsItem( settItms_t::USER_NAME_ON_CLIENTS );
for ( QModelIndexList::ConstIterator it = activatedItems.cbegin(); it != activatedItems.cend(); ++it ) { for ( QModelIndexList::ConstIterator it = activatedItems.cbegin(); it != activatedItems.cend(); ++it ) {
if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) { if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) {
Client *client = static_cast< Client* >( ( *it ).data( Qt::UserRole ).value< void * >() ); Client *client = static_cast< Client* >( ( *it ).data( Qt::UserRole ).value< void * >() );
@ -501,7 +518,7 @@ void lc::MainWindow::on_PBStartLocalzLeaf_clicked() {
QLineEdit::Normal, *lablib->GetLocalZLeafDefaultName() ); QLineEdit::Normal, *lablib->GetLocalZLeafDefaultName() );
lablib->SetLocalZLeafDefaultName( name ); lablib->SetLocalZLeafDefaultName( name );
QString program = QString{ *lablib->GetSettingsItem( settingsItems_t::LABCONTROL_INSTALLATION_DIRECTORY ) + "/scripts/start_zLeaf_labcontrol2.sh" }; QString program = QString{ *lablib->GetSettingsItem( settItms_t::LC_INST_DIR ) + "/scripts/start_zLeaf_labcontrol2.sh" };
QStringList arguments; QStringList arguments;
arguments << ui->CBzLeafVersion->currentText() << "127.0.0.1" << QString::number( ui->SBzLeafPort->value() - 7000 ) << name; arguments << ui->CBzLeafVersion->currentText() << "127.0.0.1" << QString::number( ui->SBzLeafPort->value() - 7000 ) << name;
@ -528,9 +545,9 @@ void lc::MainWindow::on_PBStartzLeaf_clicked() {
} }
QModelIndexList activated_items = ui->TVClients->selectionModel()->selectedIndexes(); QModelIndexList activated_items = ui->TVClients->selectionModel()->selectedIndexes();
const QString * const publickeyPathUser = lablib->GetSettingsItem( settingsItems_t::PUBLICKEY_PATH_USER ), const QString * const publickeyPathUser = lablib->GetSettingsItem( settItms_t::SSH_KEY_USER ),
* const serverIP = lablib->GetSettingsItem( settingsItems_t::SERVER_IP ), * const serverIP = lablib->GetSettingsItem( settItms_t::SERVER_IP ),
* const userNameOnClients = lablib->GetSettingsItem( settingsItems_t::USER_NAME_ON_CLIENTS ), * const userNameOnClients = lablib->GetSettingsItem( settItms_t::USER_NAME_ON_CLIENTS ),
* const zLeafVersion = new QString{ ui->CBzLeafVersion->currentText() }; * const zLeafVersion = new QString{ ui->CBzLeafVersion->currentText() };
for ( QModelIndexList::ConstIterator it = activated_items.cbegin(); it != activated_items.cend(); ++it ) { for ( QModelIndexList::ConstIterator it = activated_items.cbegin(); it != activated_items.cend(); ++it ) {
if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) { if ( ( *it ).data( Qt::DisplayRole ).type() != 0 ) {
@ -701,8 +718,8 @@ void lc::MainWindow::SetupWidgets() {
ui->LAdministrativeRights->setText( tr( "You don't have administrative rights." ) ); ui->LAdministrativeRights->setText( tr( "You don't have administrative rights." ) );
} }
ui->LUserName->setText( tr( "You are user %1" ).arg( lablib->GetUserNameOnServer() ) ); ui->LUserName->setText( tr( "You are user %1" ).arg( lablib->GetUserNameOnServer() ) );
if ( lablib->GetSettingsItem( settingsItems_t::USER_NAME_ON_CLIENTS ) ) { if ( lablib->GetSettingsItem( settItms_t::USER_NAME_ON_CLIENTS ) ) {
ui->RBUseLocalUser->setText( *lablib->GetSettingsItem( settingsItems_t::USER_NAME_ON_CLIENTS ) ); ui->RBUseLocalUser->setText( *lablib->GetSettingsItem( settItms_t::USER_NAME_ON_CLIENTS ) );
} else { } else {
ui->RBUseUserRoot->click(); ui->RBUseUserRoot->click();
} }
@ -715,8 +732,8 @@ void lc::MainWindow::SetupWidgets() {
ui->RBUseLocalUser->click(); ui->RBUseLocalUser->click();
// Fill the CBCommandToExecute QComboBox // Fill the CBCommandToExecute QComboBox
if ( lablib->GetSettingsItem( settingsItems_t::USER_NAME_ON_CLIENTS ) ) { if ( lablib->GetSettingsItem( settItms_t::USER_NAME_ON_CLIENTS ) ) {
ui->CBCommandToExecute->addItems( QStringList{} << "" << "apt update" << "apt full-upgrade -y" << "reboot" << "rm -rfv /home/" + *lablib->GetSettingsItem( settingsItems_t::USER_NAME_ON_CLIENTS ) + "/.mozilla" << "uname -a" ); ui->CBCommandToExecute->addItems( QStringList{} << "" << "apt update" << "apt full-upgrade -y" << "reboot" << "rm -rfv /home/" + *lablib->GetSettingsItem( settItms_t::USER_NAME_ON_CLIENTS ) + "/.mozilla" << "uname -a" );
} else { } else {
ui->CBCommandToExecute->addItems( QStringList{} << "" << "apt update" << "apt full-upgrade -y" << "reboot" << "uname -a" ); ui->CBCommandToExecute->addItems( QStringList{} << "" << "apt update" << "apt full-upgrade -y" << "reboot" << "uname -a" );
} }

Loading…
Cancel
Save