summaryrefslogtreecommitdiffstats
path: root/src/vsession.cpp
diff options
context:
space:
mode:
authorNils Schwabe2014-03-19 17:48:16 +0100
committerNils Schwabe2014-03-19 17:48:16 +0100
commitba34b15fddcd16b82338a2d88b7aee8a1654af1f (patch)
tree5c412e3d6d0f7014538877b60b4954ab523e8428 /src/vsession.cpp
parent- changed dialog desgin (diff)
downloadvmchooser2-ba34b15fddcd16b82338a2d88b7aee8a1654af1f.tar.gz
vmchooser2-ba34b15fddcd16b82338a2d88b7aee8a1654af1f.tar.xz
vmchooser2-ba34b15fddcd16b82338a2d88b7aee8a1654af1f.zip
removed the file and path option for XMLs
Diffstat (limited to 'src/vsession.cpp')
-rw-r--r--src/vsession.cpp75
1 files changed, 5 insertions, 70 deletions
diff --git a/src/vsession.cpp b/src/vsession.cpp
index e5dfba2..ebe369a 100644
--- a/src/vsession.cpp
+++ b/src/vsession.cpp
@@ -302,8 +302,7 @@ QList<Session*> VSession::readXmlFile(const QString& filepath) {
QDomDocument doc;
QFile file(filepath);
- QString backup_filename = "/tmp/vmchooser2_backup.xml";
- QFile backup_file(backup_filename);
+ QFile backup_file(xml_backup_filename);
if (!file.open(QIODevice::ReadOnly)) {
@@ -322,7 +321,7 @@ 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 " << backup_filename << " either";
+ qDebug() << "Cannot read backup file " << xml_backup_filename << " either";
}
return retval;
}
@@ -336,14 +335,14 @@ QList<Session*> VSession::readXmlFile(const QString& filepath) {
}
if (debugMode) {
- qDebug() << "Used backup file " << backup_filename;
+ qDebug() << "Used backup file " << xml_backup_filename;
}
backup_file.close();
} else {
// file is valid --> create backup file
- QFile::remove(backup_filename);
- QFile::copy(filepath, backup_filename);
+ QFile::remove(xml_backup_filename);
+ QFile::copy(filepath, xml_backup_filename);
}
file.close();
@@ -363,70 +362,6 @@ QList<Session*> VSession::readXmlFile(const QString& filepath) {
return retval;
}
-/**
- * - calls xmlfilter.sh to glob a folder for xmls
- * -> if no xmlfilter.sh is available, it globs for available xmls
- * - reads all xml files and creates for each its own VSession-struct
- */
-QList<Session*> VSession::readXmlDir(const QString& path) {
- QList<Session*> retval;
-
- if (QFile::exists(filterScript)) {
- // run filterScript
- // treat every output line as a filename and read it
- 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 + "/");
- }
- retval.append(readXmlFile(filename));
- }
-
- myFilterScript.close();
- } else {
- // iterate over all .xml files in directory <path> (and sub-directories)
- // and read them
- QDirIterator di(path,
- QDirIterator::Subdirectories |
- QDirIterator::FollowSymlinks);
- while (di.hasNext()) {
- if (!di.next().endsWith(".xml")) continue;
-
- if (!di.fileInfo().isReadable()) {
- if (debugMode) qDebug() << "skip" << di.fileInfo().absoluteFilePath() << ": xml not readable, incorrect file permissions";
- continue;
- }
-
- QList<Session*> vsessionTmp = readXmlFile(di.fileInfo().absoluteFilePath());
-
- if (vsessionTmp.isEmpty()) {
- if (debugMode) qDebug() << "skip" << di.fileInfo().absoluteFilePath() << ": reading xml failed for some reason";
- continue;
- }
-
- 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;
- }
-
- if (debugMode) qDebug() << "added " << vsessionTmp.first()->shortDescription() << " to list";
-
- retval.append(vsessionTmp);
- }
- }
- return retval;
-}
-
bool VSession::operator<(const Session& other) const {
int p0 = this->priority();
int p1 = other.priority();