From 162121941f6d7bccc4c8f4e98431441e0afe8460 Mon Sep 17 00:00:00 2001
From: Jan Darmochwal
Date: Thu, 4 Nov 2010 14:02:39 +0100
Subject: Config option: pool
* formerly vmchooser_env in vmchooser.conf
* pool/vmchooser_env in vmchooser.conf
* -P/--pools command line option
* a virtual session will only be displayed if
a) their pools attribute contains pool
b) their pools attribute is unset/empty
c) pool is unset/empty
* fix for segfault with invalid command line options
---
src/command_line_options.cpp | 9 +++++++--
src/globals.cpp | 2 ++
src/globals.h | 2 ++
src/i18n/de.ts | 22 ++++++++++++----------
src/main.cpp | 9 +++++++++
src/vsession.cpp | 9 ++++++++-
6 files changed, 40 insertions(+), 13 deletions(-)
diff --git a/src/command_line_options.cpp b/src/command_line_options.cpp
index 4ee6520..61eb3ad 100644
--- a/src/command_line_options.cpp
+++ b/src/command_line_options.cpp
@@ -7,14 +7,16 @@ CommandLineOptions::CommandLineOptions(int argc, char * const argv[]) {
static const struct option longOptions[] = {
{"config", required_argument, NULL, 'c'},
{"default", required_argument, NULL, 'd'},
+ {"pool", required_argument, NULL, 'P'},
{"path", required_argument, NULL, 'p'},
{"xpath", required_argument, NULL, 'x'},
{"size", required_argument, NULL, 's'},
{"version", no_argument, NULL, 'v'},
- {"help", no_argument, NULL, 'h'}
+ {"help", no_argument, NULL, 'h'},
+ {0, 0, 0, 0}
};
- int opt = getopt_long(argc, argv, "c:d:p:x:s:vhb", longOptions, NULL);
+ int opt = getopt_long(argc, argv, "c:d:P:p:x:s:vhb", longOptions, NULL);
if (opt == -1) break;
switch (opt) {
@@ -24,6 +26,9 @@ CommandLineOptions::CommandLineOptions(int argc, char * const argv[]) {
case 'd':
options.insert("default", optarg);
break;
+ case 'P':
+ options.insert("pool", optarg);
+ break;
case 'p':
options.insert("path", optarg);
break;
diff --git a/src/globals.cpp b/src/globals.cpp
index 0606243..7dfc222 100644
--- a/src/globals.cpp
+++ b/src/globals.cpp
@@ -18,3 +18,5 @@ const QString globalConfFile(etcPath + "/vmchooser.conf");
const QString userConfFile(userPath + "/vmchooser.conf");
const QString previousSessionFile(userPath + "/vmchooser_prev_session");
+QString pool;
+
diff --git a/src/globals.h b/src/globals.h
index a505628..6ddf350 100644
--- a/src/globals.h
+++ b/src/globals.h
@@ -30,4 +30,6 @@ extern const QString globalConfFile;
extern const QString userConfFile;
extern const QString previousSessionFile;
+extern QString pool;
+
#endif
diff --git a/src/i18n/de.ts b/src/i18n/de.ts
index 85ceb14..c81a0fe 100644
--- a/src/i18n/de.ts
+++ b/src/i18n/de.ts
@@ -8,6 +8,7 @@
- Aufruf: vmchooser [ OPTIONEN | DATEI ]
+Aufruf: vmchooser [ OPTIONEN | DATEI ]
-d, --default Name der Standardsitzung
+ -P, --pool Name der Umgebung
-p, --path Pfad zu .xml-Dateien für virtuelle Sitzungen
-x, --xpath Pfad zu .desktop-Dateien für X Sitzungen
-s, --size Fenstergröße <Breite>x<Höhe>
-v, --version Version anzeigen und beenden
-h, --help Hilfetext anzeigen und beenden
-DATEI kann eine .xml- oder .desktop-Datei sein
+ DATEI kann eine .xml- oder .desktop-Datei sein
-
-
+
+
vmchooser: Fehler beim Start der Sitzung
-
+
vmchooser: ungültige Sitzungsdatei
-
+
vmchooser: ungültige Größenangabe
-
+
vmchooser: keine Sitzungen gefunden
-
+
vmchooser: externes Skript %1 ist nicht ausführbar
@@ -119,12 +121,12 @@ DATEI kann eine .xml- oder .desktop-Datei sein
Vmchooser konnte die gewählte Sitzung nicht ausführen!
-
+
X-Sitzungen
-
+
Virtuelle Sitzungen
diff --git a/src/main.cpp b/src/main.cpp
index fbb3f67..faef051 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -33,6 +33,7 @@ int main(int argc, char *argv[]) {
"Console",
"Usage: vmchooser [ OPTIONS | FILE ]\n\n"
" -d, --default name of default session\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 x\n"
@@ -149,6 +150,14 @@ int main(int argc, char *argv[]) {
height = VMCHOOSER_DEFAULT_HEIGHT;
}
+ if (cmdOptions.contains("pool")) {
+ pool = cmdOptions.value("pool");
+ } else if (settings.contains("pool")) {
+ pool = settings.value("pool").toString();
+ } else if (settings.contains("vmchooser_env")) {
+ pool = settings.value("vmchooser_env").toString();
+ }
+
/* read session files */
QList xsessions(XSession::readSessions(xSessionPath));
QList vsessions(VSession::readXmlDir(vSessionPath));
diff --git a/src/vsession.cpp b/src/vsession.cpp
index d3c0296..edcd1e8 100644
--- a/src/vsession.cpp
+++ b/src/vsession.cpp
@@ -111,6 +111,12 @@ bool VSession::isActive() const {
}
}
+ if (!pool.isEmpty() &&
+ !getAttribute("pools").split("\\s*,\\s*").contains(pool)) {
+ // pools does not contain pool
+ return false;
+ }
+
return true;
}
@@ -182,7 +188,8 @@ void VSession::addUserAndHostname() {
QString image(this->getAttribute("image_name"));
if (QFileInfo(image).isRelative()) {
// make path to image absolute
- this->addNodeWithAttribute("image_name", this->baseDirPath_ + "/" + image);
+ this->addNodeWithAttribute("image_name",
+ this->baseDirPath_ + "/" + image);
}
// insert computername as the first child of
--
cgit v1.2.3-55-g7522