summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Schmelzer2011-07-13 11:18:13 +0200
committerSebastian Schmelzer2011-07-13 11:18:13 +0200
commit0451c3677dbd6cdac99521e59f90dca16f8739b2 (patch)
tree0bbf7466b9d03d23d483780690addb193785667d
parentupdate win7 logo (diff)
downloadvmchooser-0451c3677dbd6cdac99521e59f90dca16f8739b2.tar.gz
vmchooser-0451c3677dbd6cdac99521e59f90dca16f8739b2.tar.xz
vmchooser-0451c3677dbd6cdac99521e59f90dca16f8739b2.zip
fix problems with unreadable files
cleaned up debug messages changed pools parameter to env
-rw-r--r--src/command_line_options.cpp8
-rw-r--r--src/main.cpp6
-rw-r--r--src/vsession.cpp17
3 files changed, 21 insertions, 10 deletions
diff --git a/src/command_line_options.cpp b/src/command_line_options.cpp
index c698315..1cf1194 100644
--- a/src/command_line_options.cpp
+++ b/src/command_line_options.cpp
@@ -7,8 +7,8 @@ CommandLineOptions::CommandLineOptions(int argc, char * const argv[]) {
static const struct option longOptions[] = {
{"config", required_argument, NULL, 'c'},
{"default", required_argument, NULL, 'd'},
+ {"env", required_argument, NULL, 'e'},
{"file", required_argument, NULL, 'f'},
- {"pool", required_argument, NULL, 'P'},
{"path", required_argument, NULL, 'p'},
{"xpath", required_argument, NULL, 'x'},
{"size", required_argument, NULL, 's'},
@@ -22,7 +22,7 @@ CommandLineOptions::CommandLineOptions(int argc, char * const argv[]) {
int c;
- while ((c = getopt_long(argc, argv, "c:d:f:P:p:x:s:t:w:vhbD", longOptions, NULL)) != -1) {
+ while ((c = getopt_long(argc, argv, "c:d:e:f:p:x:s:t:w:vhbD", longOptions, NULL)) != -1) {
switch (c) {
case 'c':
options.insert("config", optarg);
@@ -36,8 +36,8 @@ CommandLineOptions::CommandLineOptions(int argc, char * const argv[]) {
case 'D':
options.insert("debugMode", "debugMode");
break;
- case 'P':
- options.insert("pool", optarg);
+ case 'e':
+ options.insert("env", optarg);
break;
case 'p':
options.insert("path", optarg);
diff --git a/src/main.cpp b/src/main.cpp
index f5853be..774f166 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -37,8 +37,8 @@ int main(int argc, char *argv[]) {
"Usage: vmchooser [ OPTIONS ]\n\n"
" -d, --default name of default session\n"
" -c, --config alternative config file\n"
+ " -e, --env name of the environment\n"
" -f, --file direct boot FILE\n"
- " -P, --pool name of the environment\n"
" -p, --path path to vmware .xml files\n"
" -x, --xpath path of X Session .desktop files\n"
" -s, --size window size <width>x<height>\n"
@@ -158,8 +158,8 @@ int main(int argc, char *argv[]) {
height = VMCHOOSER_DEFAULT_HEIGHT;
}
- if (cmdOptions.contains("pool")) {
- pool = cmdOptions.value("pool");
+ if (cmdOptions.contains("env")) {
+ pool = cmdOptions.value("env");
} else if (settings.contains("pool")) {
pool = settings.value("pool").toString();
}
diff --git a/src/vsession.cpp b/src/vsession.cpp
index 4d48326..e9059f2 100644
--- a/src/vsession.cpp
+++ b/src/vsession.cpp
@@ -110,13 +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";
+ if (debugMode) qDebug() << "Not active. Reason: 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";
+ if (debugMode) qDebug() << "Not active. Reason: tillDate is in the past";
return false;
}
}
@@ -125,7 +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";
+ if (debugMode) qDebug() << "Not active. Reason: vsession is not part of active env";
return false;
}
}
@@ -362,8 +362,19 @@ QList<Session*> VSession::readXmlDir(const QString& path) {
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;