summaryrefslogtreecommitdiffstats
path: root/src/vsession.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/vsession.cpp')
-rw-r--r--src/vsession.cpp34
1 files changed, 31 insertions, 3 deletions
diff --git a/src/vsession.cpp b/src/vsession.cpp
index 05e5159..b543c0f 100644
--- a/src/vsession.cpp
+++ b/src/vsession.cpp
@@ -39,7 +39,9 @@ void VSession::addNodeWithAttribute(const QString& nodeName,
QString VSession::icon() const {
QString icon(getAttribute("icon"));
if (icon.isEmpty()) {
- icon = "vmware";
+ if (imgtype() == VMWARE) icon = "vmware";
+ else if (imgtype() == VBOX) icon = "virtualbox";
+ else icon = "unknown";
} else if (icon.contains(".") && QDir::isRelativePath(icon)) {
// non-built-in icon with relative path
icon.prepend(baseDirPath_ + "/");
@@ -87,7 +89,7 @@ ImgType VSession::imgtype() const {
bool VSession::isActive() const {
QString value(getAttribute("active"));
- if (value.compare("false")) {
+ if (value.compare("false") == 0) {
return false;
} else if (value.count("/") == 1) {
// try to interpret value as date range
@@ -108,11 +110,13 @@ bool VSession::isActive() const {
if (fromDate.isValid() && fromDate > today) {
// fromDate is in the future
+ if (debugMode) qDebug() << "ERR: fromDate is in the future";
return false;
}
if (tillDate.isValid() && tillDate < today) {
// tillDate is in the past
+ if (debugMode) qDebug() << "ERR: tillDate is in the past";
return false;
}
}
@@ -121,6 +125,7 @@ bool VSession::isActive() const {
QStringList pools = getAttribute("pools").split("\\s*,\\s*");
if (!pools.isEmpty() && !pools.contains(pool)) {
// pools does not contain pool
+ if (debugMode) qDebug() << "ERR: pools does not contain pool";
return false;
}
}
@@ -133,6 +138,11 @@ bool VSession::isLocked() const {
return getAttribute("locked").compare("true") == 0;
}
+bool VSession::isValid() const {
+ // default to false
+ return QFile::exists(QString(this->baseDirPath_).append("/").append(getAttribute("image_name")));
+}
+
int VSession::priority() const {
return getAttribute("priority").toInt();
}
@@ -333,8 +343,10 @@ QList<Session*> VSession::readXmlDir(const QString& path) {
QProcess myFilterScript;
myFilterScript.start(filterScript, QStringList(path),
QIODevice::ReadOnly);
+ myFilterScript.waitForFinished();
while (!myFilterScript.atEnd()) {
QString filename(myFilterScript.readLine());
+ filename = filename.trimmed();
if (QDir::isRelativePath(filename)) {
filename.prepend(path + "/");
}
@@ -350,9 +362,25 @@ QList<Session*> VSession::readXmlDir(const QString& path) {
QDirIterator::FollowSymlinks);
while (di.hasNext()) {
if (!di.next().endsWith(".xml")) continue;
- retval.append(readXmlFile(di.fileInfo().absoluteFilePath()));
+ QList<Session*> vsessionTmp = readXmlFile(di.fileInfo().absoluteFilePath());
+
+ if (!vsessionTmp.first()->isValid()) {
+ if (debugMode) qDebug() << "skip" << vsessionTmp.first()->shortDescription() << ": vdi/vmdk missing";
+ continue;
+ }
+
+ if (!vsessionTmp.first()->isActive()) {
+ if (debugMode) qDebug() << "skip" << vsessionTmp.first()->shortDescription() << ": not active";
+ continue;
+ }
+
+ retval.append(vsessionTmp);
}
}
+
+ for (int i=0; i < retval.count(); i++) {
+
+ }
return retval;
}