From d5f2dddbbd6707f0093561b1c91087d6da0c966c Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Fri, 15 Jun 2018 14:50:54 +0200 Subject: Clean up globals.* (remove unused, rename constants, prefix) --- src/choosersettings.cpp | 8 +++--- src/dialog.cpp | 64 +++++++++++++++++++++++----------------------- src/globals.cpp | 44 ++++++++++++++++--------------- src/globals.h | 52 ++++++++++++++----------------------- src/main.cpp | 58 ++++++++++++++++++++--------------------- src/sessionsiconholder.cpp | 8 +++--- src/vsession.cpp | 44 +++++++++++++++---------------- 7 files changed, 133 insertions(+), 145 deletions(-) (limited to 'src') diff --git a/src/choosersettings.cpp b/src/choosersettings.cpp index 36c9a0f..28cbdb1 100644 --- a/src/choosersettings.cpp +++ b/src/choosersettings.cpp @@ -13,19 +13,19 @@ ChooserSettings* ChooserSettings::chooserSettings = NULL; ChooserSettings::ChooserSettings() { // test (and make) directory - QDir saveFileDir(QFileInfo(previousSessionFile).absoluteDir()); + QDir saveFileDir(QFileInfo(PREVIOUS_SESSION_USER).absoluteDir()); if (!saveFileDir.exists()) { if (!saveFileDir.mkpath(saveFileDir.path())) { return; } } - settings = new QSettings(previousSessionFile, QSettings::IniFormat); + settings = new QSettings(PREVIOUS_SESSION_USER, QSettings::IniFormat); settings->setIniCodec("UTF-8"); if (settings->status() != QSettings::NoError) { - if (debugMode) { - qDebug() << "Settings: " << previousSessionFile << " contains erros."; + if (g_debugMode) { + qDebug() << "Settings: " << PREVIOUS_SESSION_USER << " contains erros."; } return; } diff --git a/src/dialog.cpp b/src/dialog.cpp index 7e22962..6250114 100644 --- a/src/dialog.cpp +++ b/src/dialog.cpp @@ -141,7 +141,7 @@ void Dialog::on_treeView_doubleClicked(const QModelIndex& index) // Run session if (s->run()) { // Run session start script if the session could be initialized successfully - if (QFile::exists(sessionStartScript)) { + if (QFile::exists(SESSION_START_SCRIPT)) { // Use the current environment variables and add the necessary // information for the startUpScipt. // export session information to the environment of the process to be exec'ed @@ -359,10 +359,10 @@ void Dialog::setTheme() { QString backgroundColor, imageLeft, imageRight; QString themePathBase, themePathIni, themePathImgLeft, themePathImgRight; - if (theme.isEmpty()) return; + if (g_themeName.isEmpty()) return; - themePathBase = QString("%1/%2/").arg(VMCHOOSER_THEME_BASE).arg(theme); - themePathIni = QString("%1%2.ini").arg(themePathBase).arg(theme); + themePathBase = QString("%1/%2/").arg(VMCHOOSER_THEME_BASE).arg(g_themeName); + themePathIni = QString("%1%2.ini").arg(themePathBase).arg(g_themeName); if (!QFile::exists(themePathIni)) return; @@ -395,7 +395,7 @@ void Dialog::onCenterTimer() { QRect desktopRect = QApplication::desktop()->availableGeometry(this); QPoint center = desktopRect.center(); if (center != oldCenter_) { - if (_fullscreen) + if (g_fullscreen) this->resize(desktopRect.width(), desktopRect.height()); this->move(center.x() - this->width() / 2, center.y() - this->height() / 2); oldCenter_ = center; @@ -421,18 +421,18 @@ void Dialog::addSessionsAfterDownload(QNetworkReply* reply) { if (reply->error() != QNetworkReply::NoError) { qDebug() << "Error reading from URL: " << reply->error(); - QFile backup_file(xml_filename); + QFile backup_file(TEMP_PATH_XML_LIST); if (!backup_file.open(QIODevice::ReadOnly)) { - qDebug() << "Cannot read backup file " << xml_filename << " either"; + qDebug() << "Cannot read backup file " << TEMP_PATH_XML_LIST << " either"; this->removeStatusString(STR_LOADING); this->addStatusString(STR_URL_ERROR); return; } - qDebug() << "Using backup file " << xml_filename; + qDebug() << "Using backup file " << TEMP_PATH_XML_LIST; backup_file.close(); - temp_filename = xml_filename; + temp_filename = TEMP_PATH_XML_LIST; } else { QByteArray data = reply->readAll(); @@ -644,22 +644,22 @@ void Dialog::on_helpNewsButton_clicked() { void Dialog::addNewsAfterDownload(QNetworkReply* reply) { if (reply->error() != QNetworkReply::NoError) { - if (debugMode) { + if (g_debugMode) { qDebug() << "Could not get news. Try to get cached news."; } // try to get cached news - QFile backup_file(news_backup_filename); + QFile backup_file(TEMP_PATH_NEWS); if (!backup_file.open(QIODevice::ReadOnly)) { - if (debugMode) { - qDebug() << "Cannot read backup file " << news_backup_filename << " either"; + if (g_debugMode) { + qDebug() << "Cannot read backup file " << TEMP_PATH_NEWS << " either"; } this->ui->newsTextBrowser->setText(QCoreApplication::instance()->translate("Dialog", "Could not get news.")); return; } - if (debugMode) { - qDebug() << "Used backup file " << news_backup_filename; + if (g_debugMode) { + qDebug() << "Used backup file " << TEMP_PATH_NEWS; } backup_file.close(); return; @@ -694,10 +694,10 @@ void Dialog::addNewsAfterDownload(QNetworkReply* reply) { ChooserSettings::setSetting("last-news", QString::number(timestamp.toTime_t())); // make backup - QFile file(news_backup_filename); + QFile file(TEMP_PATH_NEWS); if (!file.open(QIODevice::WriteOnly)) { - if (debugMode) { - qDebug() << "Could not write XML to " << news_backup_filename; + if (g_debugMode) { + qDebug() << "Could not write XML to " << TEMP_PATH_NEWS; } return; } @@ -706,8 +706,8 @@ void Dialog::addNewsAfterDownload(QNetworkReply* reply) { return; } if (!file.setPermissions(QFile::ReadUser | QFile::ReadGroup | QFile::ReadOther | QFile::WriteUser | QFile::WriteGroup | QFile::WriteOther)) { - if (debugMode) { - qDebug() << "Could not change permissions of file: " << news_backup_filename; + if (g_debugMode) { + qDebug() << "Could not change permissions of file: " << TEMP_PATH_NEWS; } } file.close(); @@ -715,22 +715,22 @@ void Dialog::addNewsAfterDownload(QNetworkReply* reply) { void Dialog::addHelpAfterDownload(QNetworkReply* reply) { if (reply->error() != QNetworkReply::NoError) { - if (debugMode) { + if (g_debugMode) { qDebug() << "Could not get help xml. Try to get cached help..."; } // try to get cached news - QFile backup_file(help_backup_filename); + QFile backup_file(TEMP_PATH_HELP); if (!backup_file.open(QIODevice::ReadOnly)) { - if (debugMode) { - qDebug() << "Cannot read backup file " << help_backup_filename << " either"; + if (g_debugMode) { + qDebug() << "Cannot read backup file " << TEMP_PATH_HELP << " either"; } this->ui->helpTextBrowser->setText(QCoreApplication::instance()->translate("Dialog", "Could not get help.")); return; } - if (debugMode) { - qDebug() << "Used backup file " << help_backup_filename; + if (g_debugMode) { + qDebug() << "Used backup file " << TEMP_PATH_HELP; } backup_file.close(); return; @@ -740,7 +740,7 @@ void Dialog::addHelpAfterDownload(QNetworkReply* reply) { QDomDocument doc; if (!doc.setContent(data)) { - if (debugMode) { + if (g_debugMode) { qDebug() << "Help file contains errors."; } return; @@ -754,10 +754,10 @@ void Dialog::addHelpAfterDownload(QNetworkReply* reply) { } // make backup - QFile file(help_backup_filename); + QFile file(TEMP_PATH_HELP); if (!file.open(QIODevice::WriteOnly)) { - if (debugMode) { - qDebug() << "Could not write XML to " << help_backup_filename; + if (g_debugMode) { + qDebug() << "Could not write XML to " << TEMP_PATH_HELP; } return; } @@ -766,8 +766,8 @@ void Dialog::addHelpAfterDownload(QNetworkReply* reply) { return; } if (!file.setPermissions(QFile::ReadUser | QFile::ReadGroup | QFile::ReadOther | QFile::WriteUser | QFile::WriteGroup | QFile::WriteOther)) { - if (debugMode) { - qDebug() << "Could not change permissions of file: " << help_backup_filename; + if (g_debugMode) { + qDebug() << "Could not change permissions of file: " << TEMP_PATH_HELP; } } file.close(); diff --git a/src/globals.cpp b/src/globals.cpp index 698589d..ac14274 100644 --- a/src/globals.cpp +++ b/src/globals.cpp @@ -3,39 +3,41 @@ #include "globals.h" #include "session.h" +#define VMCHOOSER_SCRIPTS_PATH "/opt/openslx/scripts" +#define VMCHOOSER_X_SESSIONS_PATH "/usr/share/xsessions" + +static const QString userPath(QDir::homePath() + "/.config/openslx"); + //QString binPath(QApplication::applicationDirPath()); -QString binPath(VMCHOOSER_BIN_PATH); -QString scriptsPath(VMCHOOSER_SCRIPTS_PATH); -QString etcPath(VMCHOOSER_ETC_BASE_PATH); -QString vSessionPath(VMCHOOSER_VMPATH); -QString xSessionPath(VMCHOOSER_X_SESSIONS_PATH); -QString userPath(QDir::homePath() + "/.config/openslx"); +QString g_xSessionPath(VMCHOOSER_X_SESSIONS_PATH); +QString g_runVmScript(VMCHOOSER_SCRIPTS_PATH "/vmchooser-run_virt"); + + +const QString SESSION_START_SCRIPT(VMCHOOSER_SESSION_START_SCRIPT); -QString runVmScript(scriptsPath + "/vmchooser-run_virt"); -QString sessionStartScript(VMCHOOSER_SESSION_START_SCRIPT); +const QString CONFIG_FILE_GLOBAL("/opt/openslx/vmchooser/config/vmchooser.conf"); -const QString globalConfFile(etcPath + "/vmchooser.conf"); -const QString userConfFile(userPath + "/vmchooser.conf"); -const QString previousSessionFile(userPath + "/vmchooser2.ini"); +const QString CONFIG_FILE_USER(userPath + "/vmchooser.conf"); +const QString PREVIOUS_SESSION_USER(userPath + "/vmchooser2.ini"); -bool debugMode = false; +bool g_debugMode = false; bool g_pvsEnabled = false; bool g_pvsChecked = false; int g_autoQuitSeconds = 0; bool g_allowVmEdit = false; -QString pool; -QString theme; -QString basePath; +QString g_currentPoolName; +QString g_themeName; +QString g_vmBasePath; -const QString iconsTempPath("/tmp/vmchooser2/icons/"); -const QString xml_filename("/tmp/vmchooser2/vmchooser2.xml"); -const QString help_backup_filename("/tmp/vmchooser2/vmchooser2_help.xml"); -const QString news_backup_filename("/tmp/vmchooser2/vmchooser2_news.xml"); +const QString TEMP_PATH_ICONS("/tmp/vmchooser2/icons/"); +const QString TEMP_PATH_XML_LIST("/tmp/vmchooser2/vmchooser2.xml"); +const QString TEMP_PATH_HELP("/tmp/vmchooser2/vmchooser2_help.xml"); +const QString TEMP_PATH_NEWS("/tmp/vmchooser2/vmchooser2_news.xml"); -QString urlBase; +QString g_urlBase; -bool _fullscreen = false; +bool g_fullscreen = false; int g_templateHandling = TEMPLATES_IGNORE; int g_forLocationHandling = LOCATION_BUMP; diff --git a/src/globals.h b/src/globals.h index d5248dc..d0f1c75 100644 --- a/src/globals.h +++ b/src/globals.h @@ -1,65 +1,51 @@ #ifndef VMCHOOSER_GLOBALS_H #define VMCHOOSER_GLOBALS_H -#define VMCHOOSER_VERSION "0.1.0" - -#define VMCHOOSER_PLUGIN_PATH "/opt/openslx/plugin-repo/vmchooser" -#define VMCHOOSER_BIN_PATH "/opt/openslx/bin" -#define VMCHOOSER_SCRIPTS_PATH "/opt/openslx/scripts" -#define VMCHOOSER_ETC_BASE_PATH "/opt/openslx/vmchooser/config" -#define VMCHOOSER_VMPATH "/mnt/vmstore" -#define VMCHOOSER_THEME_BASE "/opt/openslx/vmchooser/themes" - -#define VMCHOOSER_X_SESSIONS_PATH "/usr/share/xsessions" +#define VMCHOOSER_VERSION "2.1.0" #define VMCHOOSER_SESSION_START_SCRIPT "/opt/openslx/vmchooser/sessionstart" +#define VMCHOOSER_THEME_BASE "/opt/openslx/vmchooser/themes" #define VMCHOOSER_DEFAULT_WIDTH 800 #define VMCHOOSER_DEFAULT_HEIGHT 600 -#define OPENSLXCONFIG "/opt/openslx/config" - -class QString; class Session; -extern bool debugMode; +extern bool g_debugMode; extern bool g_pvsEnabled; extern bool g_pvsChecked; extern int g_autoQuitSeconds; extern bool g_allowVmEdit; -extern QString binPath; -extern QString etcPath; -extern QString vSessionPath; -extern QString xSessionPath; -extern QString userPath; +extern QString g_xSessionPath; -extern QString runVmScript; +extern QString g_runVmScript; extern QString printerScript; extern QString scannerScript; // Script that is run before the xsession/vsession is started -extern QString sessionStartScript; +extern const QString SESSION_START_SCRIPT; -extern const QString globalConfFile; -extern const QString userConfFile; -extern const QString previousSessionFile; +extern const QString CONFIG_FILE_GLOBAL; +extern const QString CONFIG_FILE_USER; +extern const QString PREVIOUS_SESSION_USER; -extern QString pool; -extern QString theme; -extern QString basePath; +extern QString g_currentPoolName; +extern QString g_themeName; +extern QString g_vmBasePath; -extern const QString iconsTempPath; -extern const QString xml_filename; -extern const QString help_backup_filename; -extern const QString news_backup_filename; +extern const QString TEMP_PATH_ICONS; +extern const QString TEMP_PATH_XML_LIST; +extern const QString TEMP_PATH_HELP; +extern const QString TEMP_PATH_NEWS; -extern QString urlBase; +extern QString g_urlBase; -extern bool _fullscreen; +extern bool g_fullscreen; #define TEMPLATES_IGNORE (0) #define TEMPLATES_BUMP (1) extern int g_templateHandling; + #define LOCATION_IGNORE (0) #define LOCATION_BUMP (1) #define LOCATION_EXCLUSIVE (2) diff --git a/src/main.cpp b/src/main.cpp index a8ce657..41600a6 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -112,13 +112,13 @@ int main(int argc, char *argv[]) { std::cerr << a.translate("Console", "Requested --config not found: ").toUtf8().constData() << cmdOptions.value("config").toUtf8().constData() << std::endl; } } - if (confFile.isEmpty() && QFileInfo(userConfFile).exists()) { - confFile = userConfFile; - std::cerr << a.translate("Console", "Using user specific config: ").toUtf8().constData() << userConfFile.toUtf8().constData() << std::endl; + if (confFile.isEmpty() && QFileInfo(CONFIG_FILE_USER).exists()) { + confFile = CONFIG_FILE_USER; + std::cerr << a.translate("Console", "Using user specific config: ").toUtf8().constData() << CONFIG_FILE_USER.toUtf8().constData() << std::endl; } - if (confFile.isEmpty() && QFileInfo(globalConfFile).exists()) { - confFile = globalConfFile; - std::cerr << a.translate("Console", "Using global config: ").toUtf8().constData() << globalConfFile.toUtf8().constData() << std::endl; + if (confFile.isEmpty() && QFileInfo(CONFIG_FILE_GLOBAL).exists()) { + confFile = CONFIG_FILE_GLOBAL; + std::cerr << a.translate("Console", "Using global config: ").toUtf8().constData() << CONFIG_FILE_GLOBAL.toUtf8().constData() << std::endl; } if (confFile.isEmpty()) { std::cerr << a.translate("Console", "No config file found or given").toUtf8().constData() << std::endl; @@ -139,15 +139,15 @@ int main(int argc, char *argv[]) { } if (cmdOptions.contains("xpath")) { - xSessionPath = cmdOptions.value("xpath"); + g_xSessionPath = cmdOptions.value("xpath"); } else if (settings.contains("xpath")) { - xSessionPath = settings.value("xpath").toString(); + g_xSessionPath = settings.value("xpath").toString(); } // else keep default path if (cmdOptions.contains("url")) { - urlBase = cmdOptions.value("url"); + g_urlBase = cmdOptions.value("url"); } else if (settings.contains("url")) { - urlBase = settings.value("url").toString(); + g_urlBase = settings.value("url").toString(); } else { std::cerr << a.translate("Console", "vmchooser: no URL given").toUtf8().data() @@ -157,20 +157,20 @@ int main(int argc, char *argv[]) { // Change the runVmScript path if (cmdOptions.contains("runscript")) { - runVmScript = cmdOptions.value("runscript"); + g_runVmScript = cmdOptions.value("runscript"); } else if (settings.contains("runscript")) { - runVmScript = settings.value("runscript").toString(); + g_runVmScript = settings.value("runscript").toString(); } /* PARSE URL */ - if (!urlBase.startsWith("http://")) { + if (!g_urlBase.startsWith("http://")) { std::cerr << a.translate("Console", "vmchooser: invalid URL").toUtf8().data() << std::endl; return EXIT_FAILURE; } else { - if (!urlBase.endsWith("/")) { - urlBase += "/"; + if (!g_urlBase.endsWith("/")) { + g_urlBase += "/"; } } @@ -201,27 +201,27 @@ int main(int argc, char *argv[]) { } if (cmdOptions.contains("pool")) { - pool = cmdOptions.value("pool"); + g_currentPoolName = cmdOptions.value("pool"); } else if (settings.contains("pool")) { - pool = settings.value("pool").toString(); + g_currentPoolName = settings.value("pool").toString(); } if (cmdOptions.contains("theme")) { - theme = cmdOptions.value("theme"); + g_themeName = cmdOptions.value("theme"); } else if (settings.contains("theme")) { - theme = settings.value("theme").toString(); + g_themeName = settings.value("theme").toString(); } if (cmdOptions.contains("debugMode")) { - debugMode = true; + g_debugMode = true; } if (cmdOptions.contains("base")) { - basePath = cmdOptions.value("base"); + g_vmBasePath = cmdOptions.value("base"); } else if (settings.contains("base")) { - basePath = settings.value("base").toString(); + g_vmBasePath = settings.value("base").toString(); } else if (settings.contains("path")) { // Compatibility to v1.0 - basePath = settings.value("path").toString(); + g_vmBasePath = settings.value("path").toString(); } if (cmdOptions.contains("location-mode")) { @@ -284,7 +284,7 @@ int main(int argc, char *argv[]) { g_allowVmEdit = cmdOptions.contains("allow-vm-edit"); /* read session files */ - QList xsessions(XSession::readSessions(xSessionPath)); + QList xsessions(XSession::readSessions(g_xSessionPath)); Dialog w(defaultTab, cmdOptions.contains("exam-mode")); @@ -295,20 +295,20 @@ int main(int argc, char *argv[]) { // read xml and add items later if (cmdOptions.contains("exam-mode")) { - httpxmldownloader.makeRequest(urlBase + "list?exams=exam-mode", locationIds); + httpxmldownloader.makeRequest(g_urlBase + "list?exams=exam-mode", locationIds); } else { - httpxmldownloader.makeRequest(urlBase + "list", locationIds); + httpxmldownloader.makeRequest(g_urlBase + "list", locationIds); } /* DOWNLOAD NEWS */ HttpXmlDownloader news_downloader; news_downloader.connectSlot(&w, SLOT(addNewsAfterDownload(QNetworkReply*))); - news_downloader.makeRequest(urlBase + "news"); + news_downloader.makeRequest(g_urlBase + "news"); /* DOWNLOAD HELP-SECTION */ HttpXmlDownloader help_downloader; help_downloader.connectSlot(&w, SLOT(addHelpAfterDownload(QNetworkReply*))); - help_downloader.makeRequest(urlBase + "help"); + help_downloader.makeRequest(g_urlBase + "help"); w.setTheme(); @@ -318,7 +318,7 @@ int main(int argc, char *argv[]) { if (size == "fullscreen") { width = desktopRect.width(); height = desktopRect.height(); - _fullscreen = true; + g_fullscreen = true; } w.resize(width, height); diff --git a/src/sessionsiconholder.cpp b/src/sessionsiconholder.cpp index 872df07..5a1824e 100644 --- a/src/sessionsiconholder.cpp +++ b/src/sessionsiconholder.cpp @@ -22,11 +22,11 @@ SessionsIconHolder* SessionsIconHolder::instance = NULL; static inline QString url2filename(const QString& url) { - return iconsTempPath + QString(QCryptographicHash::hash(url.toUtf8(), QCryptographicHash::Md5).toHex()); + return TEMP_PATH_ICONS + QString(QCryptographicHash::hash(url.toUtf8(), QCryptographicHash::Md5).toHex()); } SessionsIconHolder::SessionsIconHolder() { - QDir().mkpath(iconsTempPath); + QDir().mkpath(TEMP_PATH_ICONS); } void SessionsIconHolder::afterDownload(const QUrl& url, const QByteArray& downloadedData) { @@ -35,7 +35,7 @@ void SessionsIconHolder::afterDownload(const QUrl& url, const QByteArray& downlo QString file_path(url2filename(strUrl)); QFile file(file_path); if (!file.open(QFile::WriteOnly)) { - if (debugMode) { + if (g_debugMode) { qDebug() << "Could not write file: " << file_path; } return; @@ -43,7 +43,7 @@ void SessionsIconHolder::afterDownload(const QUrl& url, const QByteArray& downlo file.write(downloadedData); if (file.write(downloadedData) != downloadedData.length()) { - if (debugMode) { + if (g_debugMode) { qDebug() << "Could not write file: " << file_path; } return; diff --git a/src/vsession.cpp b/src/vsession.cpp index 6344ec8..05b84a1 100644 --- a/src/vsession.cpp +++ b/src/vsession.cpp @@ -106,7 +106,7 @@ QString VSession::toXml() const { .toElement(); if (QFileInfo(image).isRelative()) { // make path to image absolute - path.setAttribute("param", basePath + "/" + image); + path.setAttribute("param", g_vmBasePath + "/" + image); } else { path.setAttribute("param", image); } @@ -171,7 +171,7 @@ bool VSession::isActive() const { QString value(getAttribute("active")); if (value.compare("false") == 0) { - if (debugMode) qDebug() << "'" << shortDescription() << "' not active. Reason: active == false"; + if (g_debugMode) qDebug() << "'" << shortDescription() << "' not active. Reason: active == false"; return false; } else if (value.count("/") == 1) { // try to interpret value as date range @@ -192,22 +192,22 @@ bool VSession::isActive() const { if (fromDate.isValid() && fromDate > today) { // fromDate is in the future - if (debugMode) qDebug() << "'" << shortDescription() << "' not active. Reason: fromDate is in the future"; + if (g_debugMode) qDebug() << "'" << shortDescription() << "' not active. Reason: fromDate is in the future"; return false; } if (tillDate.isValid() && tillDate < today) { // tillDate is in the past - if (debugMode) qDebug() << "'" << shortDescription() << "' not active. Reason: tillDate is in the past"; + if (g_debugMode) qDebug() << "'" << shortDescription() << "' not active. Reason: tillDate is in the past"; return false; } } - if (!pool.isEmpty()) { + if (!g_currentPoolName.isEmpty()) { QStringList pools = getAttribute("pools").split("\\s*,\\s*"); - if (!pools.isEmpty() && !pools.contains(pool)) { + if (!pools.isEmpty() && !pools.contains(g_currentPoolName)) { // pools does not contain pool - if (debugMode) qDebug() << "'" << shortDescription() << "' not active. Reason: '" << pool << "' is not part of active pool list (" << pools << ")"; + if (g_debugMode) qDebug() << "'" << shortDescription() << "' not active. Reason: '" << g_currentPoolName << "' is not part of active pool list (" << pools << ")"; return false; } } @@ -240,7 +240,7 @@ bool VSession::run() const { qDebug() << "Cannot start vsession while old one is still running"; return false; } - if (debugMode) { + if (g_debugMode) { qDebug() << "Sarting session " << this->getAttribute("short_description", "param") << " ..."; } @@ -270,7 +270,7 @@ bool VSession::run() const { tmpfile.close(); QObject::connect(&_process, SIGNAL(finished(int, QProcess::ExitStatus)), QApplication::instance(), SLOT(quit())); - _process.start(runVmScript, QStringList(tmpFileName)); + _process.start(g_runVmScript, QStringList(tmpFileName)); _process.waitForStarted(10); if (_process.state() == QProcess::Starting || _process.state() == QProcess::Running) return true; @@ -287,17 +287,17 @@ QList VSession::readXmlFile(const QString& filepath) { QDomDocument doc; QFile file(filepath); - QFile backup_file(xml_filename); + QFile backup_file(TEMP_PATH_XML_LIST); if (!file.open(QIODevice::ReadOnly)) { - if (debugMode) { + if (g_debugMode) { qDebug() << "Cannot read file: " << file.fileName(); } return sessionList; } if (!doc.setContent(&file)) { - if (debugMode) { + if (g_debugMode) { qDebug() << "XML file not valid: " << file.fileName(); } @@ -305,22 +305,22 @@ QList VSession::readXmlFile(const QString& filepath) { // try to use backup file if (!backup_file.open(QIODevice::ReadOnly)) { - if (debugMode) { - qDebug() << "Cannot read backup file " << xml_filename << " either"; + if (g_debugMode) { + qDebug() << "Cannot read backup file " << TEMP_PATH_XML_LIST << " either"; } return sessionList; } if (!doc.setContent(&backup_file)) { - if (debugMode) { + if (g_debugMode) { qDebug() << "XML file not valid: " << backup_file.fileName(); } backup_file.close(); return sessionList; } - if (debugMode) { - qDebug() << "Used backup file " << xml_filename; + if (g_debugMode) { + qDebug() << "Used backup file " << TEMP_PATH_XML_LIST; } backup_file.close(); @@ -328,11 +328,11 @@ QList VSession::readXmlFile(const QString& filepath) { file.close(); // file is valid --> create backup file - QFile::remove(xml_filename); - QFile::rename(filepath, xml_filename); - if (!QFile::setPermissions(xml_filename, QFile::ReadUser | QFile::ReadGroup | QFile::ReadOther | QFile::WriteUser | QFile::WriteGroup | QFile::WriteOther)) { - if (debugMode) { - qDebug() << "Could not change permissions of file: " << news_backup_filename; + QFile::remove(TEMP_PATH_XML_LIST); + QFile::rename(filepath, TEMP_PATH_XML_LIST); + if (!QFile::setPermissions(TEMP_PATH_XML_LIST, QFile::ReadUser | QFile::ReadGroup | QFile::ReadOther | QFile::WriteUser | QFile::WriteGroup | QFile::WriteOther)) { + if (g_debugMode) { + qDebug() << "Could not change permissions of file: " << TEMP_PATH_NEWS; } } } -- cgit v1.2.3-55-g7522