summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/vsession.cpp66
-rw-r--r--src/vsession.h1
2 files changed, 61 insertions, 6 deletions
diff --git a/src/vsession.cpp b/src/vsession.cpp
index edcd1e8..f4c2326 100644
--- a/src/vsession.cpp
+++ b/src/vsession.cpp
@@ -111,10 +111,12 @@ bool VSession::isActive() const {
}
}
- if (!pool.isEmpty() &&
- !getAttribute("pools").split("\\s*,\\s*").contains(pool)) {
- // pools does not contain pool
- return false;
+ if (!pool.isEmpty()) {
+ QStringList pools = getAttribute("pools").split("\\s*,\\s*");
+ if (!pools.isEmpty() && !pools.contains(pool)) {
+ // pools does not contain pool
+ return false;
+ }
}
return true;
@@ -199,6 +201,59 @@ void VSession::addUserAndHostname() {
this->doc_.namedItem("eintrag").insertBefore(computername, QDomNode());
}
+void VSession::mergePoolXml() {
+ QDomDocument doc;
+
+ QString poolXmlFile = etcPath + "/vmchooser-" + pool + ".xml";
+
+ QFile file(poolXmlFile);
+ if (!file.open(QIODevice::ReadOnly)) {
+ printf("mark a\n");
+ return;
+ }
+ if (!doc.setContent(&file)) {
+ printf("mark b\n");
+
+ file.close();
+ return;
+ }
+ file.close();
+
+ for (QDomElement envNode(doc.firstChildElement("environment"));
+ !envNode.isNull();
+ envNode = envNode.nextSiblingElement()) {
+ printf("mark c\n");
+
+ if (envNode.attribute("param") != pool) continue;
+
+ for (QDomElement typeNode(envNode.firstChildElement());
+ !typeNode.isNull();
+ typeNode = typeNode.nextSiblingElement()) {
+ printf("mark d\n");
+ QString type = typeNode.nodeName();
+ if (type != "shared_folders" &&
+ type != "printers" &&
+ type != "scanners") continue;
+
+ QDomElement destinationNode =
+ this->doc_.namedItem("eintrag").namedItem(type).toElement();
+
+ if (destinationNode.isNull()) {
+ // create new node
+ destinationNode = this->doc_.createElement(type);
+ this->doc_.namedItem("eintrag").appendChild(destinationNode);
+ }
+
+ for (QDomElement el(typeNode.firstChildElement());
+ !el.isNull();
+ el = el.nextSiblingElement()) {
+ printf("mark e\n");
+ destinationNode.appendChild(this->doc_.importNode(el, true));
+ }
+ }
+ }
+}
+
bool VSession::run() const {
QString command = getAttribute("command");
if (!command.isEmpty()) {
@@ -216,8 +271,7 @@ bool VSession::run() const {
session.addUserAndHostname();
- // TODO: read the group configuration XML
- // session.readGroupXml(&dat, env);
+ session.mergePoolXml();
// write xml to temporary file
QTemporaryFile tmpfile(QDir::tempPath() + "/vmchooser-XXXXXX.xml");
diff --git a/src/vsession.h b/src/vsession.h
index f9ab076..035b235 100644
--- a/src/vsession.h
+++ b/src/vsession.h
@@ -57,6 +57,7 @@ class VSession : public Session {
void addPrinters(const QString& script, const QString& type = "printer");
void addScanners(const QString& script);
void addUserAndHostname();
+ void mergePoolXml();
QString toXml() const;