@ -50,10 +50,8 @@ lc::Lablib::Lablib( QObject *argParent ) :
}
// Initialize the server for client help requests retrieval
if ( clientHelpNotificationServerPort & & ! settings - > serverIP . isEmpty ( ) ) {
if ( settings- > clientHelpNotificationServerPort & & ! settings - > serverIP . isEmpty ( ) ) {
clientHelpNotificationServer = new ClientHelpNotificationServer { clientIPsToClientsMap ,
settings - > serverIP ,
clientHelpNotificationServerPort ,
this } ;
}
}
@ -75,7 +73,7 @@ lc::Lablib::~Lablib () {
}
bool lc : : Lablib : : CheckIfUserIsAdmin ( ) const {
for ( const auto & s : adminUsers ) {
for ( const auto & s : settings- > adminUsers ) {
if ( s = = settings - > localUserName ) {
qDebug ( ) < < " User " < < settings - > localUserName < < " has administrative rights. " ;
return true ;
@ -85,23 +83,6 @@ bool lc::Lablib::CheckIfUserIsAdmin() const {
}
void lc : : Lablib : : DetectInstalledZTreeVersionsAndLaTeXHeaders ( ) {
// Detect the installed LaTeX headers
if ( ! settings - > lcInstDir . isEmpty ( ) ) {
QDir laTeXDirectory { settings - > lcInstDir , " *header.tex " , QDir : : Name ,
QDir : : CaseSensitive | QDir : : Files | QDir : : Readable } ;
if ( ! laTeXDirectory . exists ( ) | | laTeXDirectory . entryList ( ) . isEmpty ( ) ) {
QMessageBox messageBox { QMessageBox : : Critical , tr ( " No LaTeX headers found " ) ,
tr ( " No LaTeX headers could be found in '%1'. Receipts printing will not work " )
. arg ( settings - > lcInstDir ) , QMessageBox : : Ok } ;
messageBox . exec ( ) ;
installedLaTeXHeaders = new QStringList { " None found " } ;
qDebug ( ) < < " No LaTeX headers could be found in " < < settings - > lcInstDir ;
} else {
installedLaTeXHeaders = new QStringList { laTeXDirectory . entryList ( ) } ;
installedLaTeXHeaders - > replaceInStrings ( " _header.tex " , " " ) ;
qDebug ( ) < < " LaTeX headers: " < < installedLaTeXHeaders - > join ( " / " ) ;
}
}
}
void lc : : Lablib : : GotNetstatQueryResult ( QStringList * argActiveZLeafConnections ) {
@ -117,66 +98,6 @@ void lc::Lablib::GotNetstatQueryResult( QStringList *argActiveZLeafConnections )
}
void lc : : Lablib : : ReadSettings ( ) {
// Let the local zLeaf name default to 'local' if none was given in the settings
if ( settings - > GetLocalzLeafName ( ) . isEmpty ( ) ) {
settings - > SetLocalzLeafName ( tr ( " local " ) ) ;
}
// Read the list of users with administrative rights
if ( ! labSettings . contains ( " admin_users " ) ) {
QMessageBox messageBox { QMessageBox : : Information , tr ( " 'admin_users' not set " ) ,
tr ( " The 'admin_users' variable was not set. No users will be able to conduct administrative tasks. " ) } ;
messageBox . exec ( ) ;
qDebug ( ) < < " 'admin_users' was not set. No permission for administrative tasks. " ;
} else {
adminUsers = labSettings . value ( " admin_users " , " " ) . toString ( )
. split ( ' | ' , QString : : SkipEmptyParts , Qt : : CaseInsensitive ) ;
qDebug ( ) < < " 'adminUsers': " < < adminUsers . join ( " / " ) ;
}
// Read the port the ClientHelpNotificationServer shall listen on
clientHelpNotificationServerPort = labSettings . value ( " client_help_server_port " , 0 ) . toUInt ( ) ;
if ( ! clientHelpNotificationServerPort ) {
QMessageBox messageBox { QMessageBox : : Information , tr ( " The ClientHelpNotificationServer will be deactivated " ) ,
tr ( " The 'client_help_server_port' variable was not set or set to zero. The ClientHelpNotificationServer will be deactivated. Clients' help requests will be ignored by the server. " ) } ;
messageBox . exec ( ) ;
qDebug ( ) < < " The ClientHelpNotificationServer will be deactivated since "
" 'client_help_server_port' was not set or set to zero. " ;
} else {
qDebug ( ) < < " 'clientHelpNotificationServerPort': " < < clientHelpNotificationServerPort ;
}
// Read the default receipt index for the 'CBReceipts' combobox
if ( ! labSettings . contains ( " default_receipt_index " ) ) {
QMessageBox messageBox { QMessageBox : : Information , tr ( " 'default_receipt_index' not set " ) ,
tr ( " The 'default_receipt_index' variable was not set. "
" It will default to '0'. " ) } ;
messageBox . exec ( ) ;
qDebug ( ) < < " 'default_receipt_index' was not set. It will default to '0'. " ;
}
defaultReceiptIndex = labSettings . value ( " default_receipt_index " , 0 ) . toInt ( ) ;
qDebug ( ) < < " 'defaultReceiptIndex': " < < defaultReceiptIndex ;
// Read the initial port number
if ( ! labSettings . contains ( " initial_port " ) ) {
QMessageBox messageBox { QMessageBox : : Information , tr ( " 'initial_port' not set " ) ,
tr ( " The 'initial_port' variable was not set. Labcontrol will default to port 7000 for new zTree instances. " ) } ;
messageBox . exec ( ) ;
qDebug ( ) < < " 'initial_port' was not set. "
" Labcontrol will default to port 7000 for new zTree instances. " ;
}
chosenZTreePort = labSettings . value ( " initial_port " , 7000 ) . toInt ( ) ;
qDebug ( ) < < " 'initial_port': " < < chosenZTreePort ;
// Get a list of available webcams in the lab
if ( ! labSettings . contains ( " webcams " ) ) {
QMessageBox messageBox { QMessageBox : : Information , tr ( " 'webcams' not set " ) ,
tr ( " The 'webcams' variable was not set. "
" No stationary webcams will be available. " ) } ;
messageBox . exec ( ) ;
qDebug ( ) < < " 'webcams' was not set. No stationary webcams will be available. " ;
}
// Get the client quantity to check the value lists for clients creation for correct length
int clientQuantity = 0 ;
if ( ! labSettings . contains ( " client_quantity " ) ) {
@ -255,16 +176,6 @@ void lc::Lablib::ReadSettings() {
}
}
void lc : : Lablib : : SetChosenZTreeDataTargetPath ( const QString & argZTreeDataTargetPath ) {
chosenZTreeDataTargetPath = argZTreeDataTargetPath ;
qDebug ( ) < < " 'chosenZTreeDataTargetPath' set to: " < < chosenZTreeDataTargetPath ;
}
void lc : : Lablib : : SetChosenZTreePort ( const int & argPort ) {
chosenZTreePort = argPort ;
qDebug ( ) < < " 'chosenZTreePort' set to: " < < chosenZTreePort ;
}
void lc : : Lablib : : SetPrintReceiptsForLocalClients ( const bool & argPrintReceiptsForLocalClients ) {
PrintReceiptsForLocalClients = argPrintReceiptsForLocalClients ;
qDebug ( ) < < " Set 'PrintReceiptsForLocalClients' to: " < < PrintReceiptsForLocalClients ;