|
|
|
@ -1,5 +1,5 @@
|
|
|
|
|
/*
|
|
|
|
|
* Copyright 2014-2016 Markus Prasser
|
|
|
|
|
* Copyright 2014-2018 Markus Prasser, Tobias Weiss
|
|
|
|
|
*
|
|
|
|
|
* This file is part of Labcontrol.
|
|
|
|
|
*
|
|
|
|
@ -50,12 +50,14 @@ lc::Lablib::Lablib( QObject *argParent ) :
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Initialize the server for client help requests retrieval
|
|
|
|
|
if ( settings->clientHelpNotificationServerPort && !settings->serverIP.isEmpty() ) {
|
|
|
|
|
if (settings->clientHelpNotificationServerPort
|
|
|
|
|
&& !settings->serverIP.isEmpty()) {
|
|
|
|
|
clientHelpNotificationServer = new ClientHelpNotificationServer{this};
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lc::Lablib::~Lablib () {
|
|
|
|
|
lc::Lablib::~Lablib ()
|
|
|
|
|
{
|
|
|
|
|
if (netstatTimer) {
|
|
|
|
|
netstatTimer->stop();
|
|
|
|
|
delete netstatTimer;
|
|
|
|
@ -64,50 +66,53 @@ lc::Lablib::~Lablib () {
|
|
|
|
|
netstatThread.wait();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool lc::Lablib::CheckIfUserIsAdmin() const {
|
|
|
|
|
bool lc::Lablib::CheckIfUserIsAdmin() const
|
|
|
|
|
{
|
|
|
|
|
for (const auto &s : settings->adminUsers) {
|
|
|
|
|
if (s == settings->localUserName) {
|
|
|
|
|
qDebug() << "User" << settings->localUserName << "has administrative rights.";
|
|
|
|
|
qDebug() << "User" << settings->localUserName
|
|
|
|
|
<< "has administrative rights.";
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void lc::Lablib::DetectInstalledZTreeVersionsAndLaTeXHeaders() {
|
|
|
|
|
void lc::Lablib::DetectInstalledZTreeVersionsAndLaTeXHeaders()
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void lc::Lablib::GotNetstatQueryResult( QStringList *argActiveZLeafConnections ) {
|
|
|
|
|
void lc::Lablib::GotNetstatQueryResult(QStringList *argActiveZLeafConnections)
|
|
|
|
|
{
|
|
|
|
|
if (argActiveZLeafConnections != nullptr) {
|
|
|
|
|
for (auto s : *argActiveZLeafConnections) {
|
|
|
|
|
// Set all given clients' statuses to 'ZLEAF_RUNNING'
|
|
|
|
|
emit ZLEAF_RUNNING( s );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
} else
|
|
|
|
|
qDebug() << "Netstat status query failed.";
|
|
|
|
|
delete argActiveZLeafConnections;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void lc::Lablib::ShowOrsee() {
|
|
|
|
|
void lc::Lablib::ShowOrsee()
|
|
|
|
|
{
|
|
|
|
|
QProcess showOrseeProcess;
|
|
|
|
|
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
|
|
|
|
|
showOrseeProcess.setProcessEnvironment( env );
|
|
|
|
|
showOrseeProcess.setProcessEnvironment(QProcessEnvironment::systemEnvironment());
|
|
|
|
|
QString program{settings->browserCmd};
|
|
|
|
|
QStringList arguments{ QStringList{} << settings->orseeUrl };
|
|
|
|
|
const QStringList arguments{settings->orseeUrl};
|
|
|
|
|
showOrseeProcess.startDetached(program, arguments);
|
|
|
|
|
|
|
|
|
|
// Output message via the debug messages tab
|
|
|
|
|
qDebug() << program << arguments.join(" ");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void lc::Lablib::ShowPreprints() {
|
|
|
|
|
void lc::Lablib::ShowPreprints()
|
|
|
|
|
{
|
|
|
|
|
// Start the process
|
|
|
|
|
QProcess showPreprintsProcess;
|
|
|
|
|
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
|
|
|
|
|
showPreprintsProcess.setProcessEnvironment( env );
|
|
|
|
|
QString program{ settings->fileMngr };
|
|
|
|
|
QStringList arguments{ QStringList{} << settings->lcDataDir + "/preprints" };
|
|
|
|
|
showPreprintsProcess.setProcessEnvironment(QProcessEnvironment::systemEnvironment());
|
|
|
|
|
const QString program{settings->fileMngr};
|
|
|
|
|
const QStringList arguments{settings->lcDataDir + "/preprints"};
|
|
|
|
|
showPreprintsProcess.startDetached(program, arguments);
|
|
|
|
|
|
|
|
|
|
// Output message via the debug messages tab
|
|
|
|
@ -118,7 +123,8 @@ void lc::Lablib::StartNewSession( QVector< Client* > argAssocCl,
|
|
|
|
|
QString argParticipNameReplacement,
|
|
|
|
|
bool argPrintLocalReceipts, QString argReceiptsHeader,
|
|
|
|
|
QString argzTreeDataTargetPath, quint16 argzTreePort,
|
|
|
|
|
QString argzTreeVersion ) {
|
|
|
|
|
QString argzTreeVersion)
|
|
|
|
|
{
|
|
|
|
|
if (!QDir(argzTreeDataTargetPath).exists()) {
|
|
|
|
|
QMessageBox messageBox{QMessageBox::Critical, tr("Data target path does not exist"),
|
|
|
|
|
tr("Your chosen data target path does not exist."
|
|
|
|
@ -126,8 +132,8 @@ void lc::Lablib::StartNewSession( QVector< Client* > argAssocCl,
|
|
|
|
|
QMessageBox::Yes | QMessageBox::No};
|
|
|
|
|
messageBox.exec();
|
|
|
|
|
if (messageBox.clickedButton() == messageBox.button(QMessageBox::No)) {
|
|
|
|
|
QMessageBox messageBox{ QMessageBox::Critical, tr( "Data target directory will not"
|
|
|
|
|
" be created" ),
|
|
|
|
|
QMessageBox messageBox{QMessageBox::Critical,
|
|
|
|
|
tr("Data target directory will not be created"),
|
|
|
|
|
tr("Your chosen data target directory does not exist and"
|
|
|
|
|
" will not be created. Please choose another one."),
|
|
|
|
|
QMessageBox::Ok};
|
|
|
|
@ -135,8 +141,8 @@ void lc::Lablib::StartNewSession( QVector< Client* > argAssocCl,
|
|
|
|
|
return;
|
|
|
|
|
} else {
|
|
|
|
|
if (!QDir().mkpath(argzTreeDataTargetPath)) {
|
|
|
|
|
QMessageBox messageBox{ QMessageBox::Critical, tr( "Data target directory could"
|
|
|
|
|
" not be created" ),
|
|
|
|
|
QMessageBox messageBox{QMessageBox::Critical,
|
|
|
|
|
tr("Data target directory could not be created"),
|
|
|
|
|
tr("Your chosen data target directory does not exist"
|
|
|
|
|
" and could not be created. Please choose another"
|
|
|
|
|
" one."), QMessageBox::Ok};
|
|
|
|
@ -153,8 +159,7 @@ void lc::Lablib::StartNewSession( QVector< Client* > argAssocCl,
|
|
|
|
|
argParticipNameReplacement,
|
|
|
|
|
argReceiptsHeader});
|
|
|
|
|
occupiedPorts.append(sessionsModel->back()->zTreePort);
|
|
|
|
|
}
|
|
|
|
|
catch ( Session::lcDataTargetPathCreationFailed ) {
|
|
|
|
|
} catch (Session::lcDataTargetPathCreationFailed) {
|
|
|
|
|
QMessageBox::information(nullptr, tr("Chosen data target path could not be created"),
|
|
|
|
|
tr("The path specified by your chosen data target path '%1'"
|
|
|
|
|
" could not be created. Please check if it is a valid"
|
|
|
|
@ -163,13 +168,15 @@ void lc::Lablib::StartNewSession( QVector< Client* > argAssocCl,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void lc::Lablib::SetLocalZLeafDefaultName( const QString &argName ) {
|
|
|
|
|
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 lc::Lablib::getzLeafArgs(int sessionPort, QString zleafVersion)
|
|
|
|
|
{
|
|
|
|
|
QStringList arguments;
|
|
|
|
|
if (sessionPort == 7000) {
|
|
|
|
|
arguments << "DISPLAY=:0.0" << settings->tasksetCmd << "0x00000001" << settings->wineCmd
|
|
|
|
|