diff --git a/data/Labcontrol.conf b/data/Labcontrol.conf index ac4c646..d04b702 100755 --- a/data/Labcontrol.conf +++ b/data/Labcontrol.conf @@ -23,9 +23,9 @@ default_receipt_index=0 # The URL address of your lab's ORSEE orsee_url=http://yourORSEEserver.tld # URLs to available webcams -webcams=http://user:pass@webcam_left|http://user:pass@webcam_right +webcams=http://user:pass@webcam_right|http://user:pass@webcam_left # Display names for the webcams -webcam_names="Webcam right|Webcam left" +webcams_names="Webcam right|Webcam left" ### Client settings # The client settings are represented as an array. So the info of the first client stands in the first field in every section and the same is valid for the other clients with other indices each. diff --git a/src/Lib/client.cpp b/src/Lib/client.cpp index a3629ad..95045b3 100755 --- a/src/Lib/client.cpp +++ b/src/Lib/client.cpp @@ -23,8 +23,10 @@ #include "client.h" #include "settings.h" +#include "lablib.h" extern std::unique_ptr< lc::Settings > settings; +extern std::unique_ptr< lc::Lablib > lablib; lc::Client::Client( const QString &argIP, const QString &argMAC, const QString &argName, unsigned short int argXPosition, unsigned short int argYPosition, @@ -250,7 +252,7 @@ void lc::Client::Shutdown() { GotStatusChanged( state_t::SHUTTING_DOWN ); } -void lc::Client::StartZLeaf( const QString * argFakeName ) { +void lc::Client::StartZLeaf( const QString * argFakeName, QString cmd ) { if ( state < state_t::RESPONDING || zLeafVersion.isEmpty() || GetSessionPort() < 7000 ) { return; } @@ -269,32 +271,22 @@ void lc::Client::StartZLeaf( const QString * argFakeName ) { if ( ( messageBoxRunningZLeafFound.get() != nullptr && messageBoxRunningZLeafFound->clickedButton() - == messageBoxRunningZLeafFound->button( QMessageBox::Yes ) ) + == messageBoxRunningZLeafFound->button( QMessageBox::Yes ) ) || state != state_t::ZLEAF_RUNNING ) { QStringList arguments; if ( argFakeName == nullptr && GetSessionPort() == 7000 ) { arguments << "-i" << settings->pkeyPathUser << QString{ settings->userNameOnClients + "@" + ip } - << "DISPLAY=:0.0" << settings->tasksetCmd << "0x00000001" << settings->wineCmd - << QString{ settings->zTreeInstDir + "/zTree_" + GetzLeafVersion() + "/zleaf.exe" } - << "/server" << settings->serverIP; + << cmd; + } else if ( argFakeName == nullptr ) { + arguments << "-i" << settings->pkeyPathUser + << QString{ settings->userNameOnClients + "@" + ip } + << cmd; } else { - if ( argFakeName == nullptr ) { - arguments << "-i" << settings->pkeyPathUser - << QString{ settings->userNameOnClients + "@" + ip } - << "DISPLAY=:0.0" << settings->tasksetCmd << "0x00000001" << settings->wineCmd - << QString{ settings->zTreeInstDir + "/zTree_" + GetzLeafVersion() + "/zleaf.exe" } - << "/server" << settings->serverIP << "/channel" - << QString::number( GetSessionPort() - 7000 ); - } else { - arguments << "-i" << settings->pkeyPathUser - << QString{ settings->userNameOnClients + "@" + ip } - << "DISPLAY=:0.0" << settings->tasksetCmd << "0x00000001" << settings->wineCmd - << QString{ settings->zTreeInstDir + "/zTree_" + GetzLeafVersion() + "/zleaf.exe" } - << "/server" << settings->serverIP << "/channel" - << QString::number( GetSessionPort() - 7000 ) - << "/name" << *argFakeName; - } + arguments << "-i" << settings->pkeyPathUser + << QString{ settings->userNameOnClients + "@" + ip } + << cmd + << "/name" << *argFakeName; } // Start the process diff --git a/src/Lib/client.h b/src/Lib/client.h index 6cf1893..2b75897 100755 --- a/src/Lib/client.h +++ b/src/Lib/client.h @@ -96,7 +96,7 @@ public: void OpenFilesystem( const QString * const argUserToBeUsed ); /*! * \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) */ void OpenTerminal( const QString &argCommand, const bool &argOpenAsRoot ); @@ -109,16 +109,19 @@ public: * \brief Shuts down the client */ void Shutdown(); - //! 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) + * \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) */ - void StartZLeaf(const QString *argFakeName = nullptr ); + void StartZLeaf(const QString *argFakeName = nullptr, QString cmd = "" ); + /*! * \brief Opens a browser window on the client * @param argURL URL to open in clients browser */ void StartClientBrowser( const QString *argURL = nullptr, const bool *argFullscreen = nullptr ); + /*! * \brief Closes all browser instances */ diff --git a/src/Lib/lablib.cpp b/src/Lib/lablib.cpp index 7fc5729..aef9889 100755 --- a/src/Lib/lablib.cpp +++ b/src/Lib/lablib.cpp @@ -167,3 +167,20 @@ void lc::Lablib::SetLocalZLeafDefaultName( const QString &argName ) { settings->SetLocalzLeafName( argName ); labSettings.setValue( "local_zLeaf_name", argName ); } + +//Returns the commandline that is issued on the client when zleaf is started +QStringList lc::Lablib::getzLeafArgs( int sessionPort, QString zleafVersion ){ + QStringList arguments; + if ( sessionPort == 7000 ) { + arguments << "DISPLAY=:0.0" << settings->tasksetCmd << "0x00000001" << settings->wineCmd + << QString{ settings->zTreeInstDir + "/zTree_" + zleafVersion + "/zleaf.exe" } + << "/server" << settings->serverIP; + } else { + arguments << "DISPLAY=:0.0" << settings->tasksetCmd << "0x00000001" << settings->wineCmd + << QString{ settings->zTreeInstDir + "/zTree_" + zleafVersion + "/zleaf.exe" } + << "/server" << settings->serverIP << "/channel" + << QString::number( sessionPort- 7000 ); + } + + return arguments; +} diff --git a/src/Lib/lablib.h b/src/Lib/lablib.h index 18afbdb..68764aa 100755 --- a/src/Lib/lablib.h +++ b/src/Lib/lablib.h @@ -93,6 +93,14 @@ public: QString argzTreeDataTargetPath, quint16 argzTreePort, QString argzTreeVersion ); + /*! + * \brief Returns the commandline to issue on the client(s) in order to start zLeaf + * @param sessionPort The port zLeaf shall connect to + * @param zLeafVersion zLeaf Version to start + */ + QStringList getzLeafArgs( int sessionPort, QString zleafVersion ); + + public slots: signals: diff --git a/src/Lib/settings.cpp b/src/Lib/settings.cpp index 11e6d14..7214061 100755 --- a/src/Lib/settings.cpp +++ b/src/Lib/settings.cpp @@ -112,6 +112,8 @@ lc::Settings::Settings( const QSettings &argSettings, QObject *argParent ) : argSettings, true ) }, webcams{ argSettings.value( "webcams", "" ).toString().split( '|', QString::SkipEmptyParts, Qt::CaseInsensitive ) }, + webcams_names{ argSettings.value( "webcams_names", "" ).toString().split( '|', QString::SkipEmptyParts, + Qt::CaseInsensitive ) }, wineCmd{ ReadSettingsItem( "wine_command", "Running z-Leaves or z-Tree will be possible.", argSettings, true ) }, diff --git a/src/Lib/settings.h b/src/Lib/settings.h index 42398b4..685f66b 100755 --- a/src/Lib/settings.h +++ b/src/Lib/settings.h @@ -78,6 +78,7 @@ public: const QString wakeonlanCmd; const QString webcamDisplayCmd; const QStringList webcams; + const QStringList webcams_names; const QString wineCmd; const QString wmctrlCmd; const QString xsetCmd; diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index e720c69..83df214 100755 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -106,7 +106,7 @@ void lc::MainWindow::DisableDisfunctionalWidgets() { if ( zTreeEntries.isEmpty() ) { ui->CBClientNames->setEnabled( false ); //ui->GBzTree->setEnabled( false ); - ui->LFakeName->setEnabled( false ); + ui->L_FakeName->setEnabled( false ); ui->PBRunzLeaf->setEnabled( false ); ui->PBStartLocalzLeaf->setEnabled( false ); ui->PBStartzLeaf->setEnabled( false ); @@ -123,8 +123,8 @@ void lc::MainWindow::DisableDisfunctionalWidgets() { ui->CBWebcamChooser->setEnabled( false ); ui->GBClientActions->setEnabled( false ); ui->LEFilePath->setEnabled( false ); - ui->LFakeName->setEnabled( false ); - ui->LWebcamChooser->setEnabled( false ); + ui->L_FakeName->setEnabled( false ); + ui->L_WebcamChooser->setEnabled( false ); ui->PBBeamFile->setEnabled( false ); ui->PBChooseFile->setEnabled( false ); ui->PBKillLocalzLeaf->setEnabled( false ); @@ -154,7 +154,7 @@ void lc::MainWindow::DisableDisfunctionalWidgets() { || settings->userNameOnClients.isEmpty() ) { ui->CBClientNames->setEnabled( false ); ui->LEFilePath->setEnabled( false ); - ui->LFakeName->setEnabled( false ); + ui->L_FakeName->setEnabled( false ); ui->PBBeamFile->setEnabled( false ); ui->PBChooseFile->setEnabled( false ); ui->PBKillzLeaf->setEnabled( false ); @@ -195,7 +195,7 @@ void lc::MainWindow::DisableDisfunctionalWidgets() { if ( settings->sshCmd.isEmpty() ) { ui->CBClientNames->setEnabled( false ); ui->GBClientActions->setEnabled( false ); - ui->LFakeName->setEnabled( false ); + ui->L_FakeName->setEnabled( false ); ui->LEFilePath->setEnabled( false ); ui->PBBeamFile->setEnabled( false ); ui->PBChooseFile->setEnabled( false ); @@ -208,7 +208,7 @@ void lc::MainWindow::DisableDisfunctionalWidgets() { if ( settings->tasksetCmd.isEmpty() ) { ui->CBClientNames->setEnabled( false ); - ui->LFakeName->setEnabled( false ); + ui->L_FakeName->setEnabled( false ); ui->PBRunzLeaf->setEnabled( false ); ui->PBStartSession->setEnabled( false ); ui->PBStartLocalzLeaf->setEnabled( false ); @@ -236,12 +236,12 @@ void lc::MainWindow::DisableDisfunctionalWidgets() { if ( settings->webcamDisplayCmd.isEmpty() || settings->webcams.isEmpty() ) { ui->CBWebcamChooser->setEnabled( false ); - ui->LWebcamChooser->setEnabled( false ); + ui->L_WebcamChooser->setEnabled( false ); } if ( settings->wineCmd.isEmpty() ) { ui->CBClientNames->setEnabled( false ); - ui->LFakeName->setEnabled( false ); + ui->L_FakeName->setEnabled( false ); ui->PBRunzLeaf->setEnabled( false ); //ui->PBStartSession->setEnabled( false ); ui->PBStartLocalzLeaf->setEnabled( false ); @@ -250,7 +250,7 @@ void lc::MainWindow::DisableDisfunctionalWidgets() { if ( settings->zTreeInstDir.isEmpty() ) { ui->CBClientNames->setEnabled( false ); - ui->LFakeName->setEnabled( false ); + ui->L_FakeName->setEnabled( false ); ui->PBRunzLeaf->setEnabled( false ); ui->PBStartSession->setEnabled( false ); ui->PBStartLocalzLeaf->setEnabled( false ); @@ -375,7 +375,7 @@ void lc::MainWindow::SetupWidgets() { ui->CBClientNames->setEnabled( false ); ui->GBClientActions->setEnabled( false ); ui->LEFilePath->setEnabled( false ); - ui->LFakeName->setEnabled( false ); + ui->L_FakeName->setEnabled( false ); ui->PBBeamFile->setEnabled( false ); ui->PBChooseFile->setEnabled( false ); ui->PBRunzLeaf->setEnabled( false ); @@ -385,18 +385,18 @@ void lc::MainWindow::SetupWidgets() { // Fill the 'CBWebcamChooser' with all available network webcams if ( !settings->webcams.isEmpty() ) { - for ( const auto &s : settings->webcams ) + for ( const auto &s : settings->webcams_names ) ui->CBWebcamChooser->addItem( s ); } // Disable the admin tab if the user has no administrative rights and set it up if ( CheckIfUserIsAdmin() ) { ui->TAdminActions->setEnabled( true ); - ui->LAdministrativeRights->setText( tr( "You have administrative rights." ) ); + ui->L_AdministrativeRights->setText( tr( "You have administrative rights." ) ); } else { - ui->LAdministrativeRights->setText( tr( "You don't have administrative rights." ) ); + ui->L_AdministrativeRights->setText( tr( "You don't have administrative rights." ) ); } - ui->LUserName->setText( tr( "You are user %1" ).arg( settings->localUserName ) ); + ui->L_UserName->setText( tr( "You are user %1" ).arg( settings->localUserName ) ); if ( !settings->userNameOnClients.isEmpty() ) { ui->RBUseLocalUser->setText( settings->userNameOnClients ); } else { @@ -569,7 +569,10 @@ void lc::MainWindow::on_CBWebcamChooser_activated( int argIndex ) { if ( argIndex != 0 ) { QString program{ settings->webcamDisplayCmd }; QStringList arguments; - arguments << ui->CBWebcamChooser->currentText(); + + // Attention argIndex is NOT 0-based + arguments << settings->webcams[argIndex-1]; + qDebug() << "Webcam" << arguments << "will be opened"; QProcess showWebcamProcess; QProcessEnvironment env = QProcessEnvironment::systemEnvironment(); @@ -674,6 +677,7 @@ void lc::MainWindow::StartLocalzLeaf( QString argzLeafName, QString argzLeafVers arguments << "/size" << QString{ settings->localzLeafSize }; } + qDebug() << "Start local zLeaf:" << arguments; startProc.startDetached( settings->tasksetCmd, arguments ); } @@ -789,19 +793,24 @@ void lc::MainWindow::on_PBStartSession_clicked() { static_cast< quint16 >( ui->SBPort->value() ), ui->CBzTreeVersion->currentText() ); + //Display the command line + QString cmd = this->lablib->getzLeafArgs( ui->SBPort->value(), ui->CBzTreeVersion->currentText()).join(" "); + ui->LEzLeafCommandline->setText(cmd); + //Start z-Leaf on selected clients if checkbox is activated if( ui->ChBautoStartClientZleaf->isChecked() ) { for ( auto cit = activatedItems.cbegin(); cit != activatedItems.cend(); ++cit ) { if ( ( *cit ).data( Qt::DisplayRole ).type() != 0 ) { Client *client = static_cast< Client* >( ( *cit ).data( Qt::UserRole ).value< void * >() ); - client->StartZLeaf( nullptr ); + client->StartZLeaf( nullptr, cmd ); } } } - //Set port to +1 + //Set chosen Port + settings->SetChosenZTreePort(ui->SBPort->text().toInt()); + // Increment port number int newPort = ui->SBPort->text().toInt() + 1; - settings->SetChosenZTreePort(newPort); ui->SBPort->setValue(newPort); } diff --git a/src/mainwindow.ui b/src/mainwindow.ui index 8278855..da11085 100755 --- a/src/mainwindow.ui +++ b/src/mainwindow.ui @@ -101,7 +101,7 @@ - + Plan a session or print attendee list @@ -122,7 +122,7 @@ - + Print local files @@ -153,7 +153,7 @@ - + Show webcams @@ -207,7 +207,7 @@ - + Switch the selected clients on or off @@ -248,7 +248,7 @@ - + Remote control the selected clients @@ -329,7 +329,7 @@ - + Start browser on the selected clients @@ -338,7 +338,7 @@ - + URL: @@ -425,7 +425,7 @@ - + 50 @@ -530,7 +530,7 @@ - Data target path: + Data target path (No whitespaces allowed) @@ -708,14 +708,14 @@ - + command line to be executed - + 0 @@ -742,7 +742,7 @@ - + true @@ -796,7 +796,7 @@ - + Local zLeaf @@ -855,14 +855,14 @@ - + TextLabel - + TextLabel @@ -880,7 +880,7 @@ - + User to be used for remote terminal session: