From 5f450cd48bae1a3c833b93089152f6b308d43c24 Mon Sep 17 00:00:00 2001 From: Sebastian Schmelzer Date: Fri, 4 Mar 2011 18:14:37 +0100 Subject: * add debug mode * implement isValid() for vsessions (checks vmdk/vbox existence) * make use of isValid() and isActive() when filling the session list * add icons for vbox, lxde, unknown images, failsafe/term * use exec to guess xsession icon instead of desciption * FIX: remove newlines/whitespaces from xmlfilter.sh output --- src/vsession.cpp | 34 +++++++++++++++++++++++++++++++--- 1 file changed, 31 insertions(+), 3 deletions(-) (limited to 'src/vsession.cpp') 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 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 VSession::readXmlDir(const QString& path) { QDirIterator::FollowSymlinks); while (di.hasNext()) { if (!di.next().endsWith(".xml")) continue; - retval.append(readXmlFile(di.fileInfo().absoluteFilePath())); + QList 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; } -- cgit v1.2.3-55-g7522