summaryrefslogtreecommitdiffstats
path: root/src/vsession.cpp
diff options
context:
space:
mode:
authorSimon Rettberg2018-06-15 14:50:54 +0200
committerSimon Rettberg2018-06-15 14:50:54 +0200
commitd5f2dddbbd6707f0093561b1c91087d6da0c966c (patch)
tree980b26f888abeb467edabffd406fd00fc0761f41 /src/vsession.cpp
parentAdd i3 icon (diff)
downloadvmchooser2-d5f2dddbbd6707f0093561b1c91087d6da0c966c.tar.gz
vmchooser2-d5f2dddbbd6707f0093561b1c91087d6da0c966c.tar.xz
vmchooser2-d5f2dddbbd6707f0093561b1c91087d6da0c966c.zip
Clean up globals.* (remove unused, rename constants, prefix)
Diffstat (limited to 'src/vsession.cpp')
-rw-r--r--src/vsession.cpp44
1 files changed, 22 insertions, 22 deletions
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<Session*> 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<Session*> 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<Session*> 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;
}
}
}