summaryrefslogtreecommitdiffstats
path: root/src/vsession.cpp
diff options
context:
space:
mode:
authorNils Schwabe2014-03-04 17:54:57 +0100
committerNils Schwabe2014-03-04 17:54:57 +0100
commit03b7858c880ea1fba3915af17c55b42d5e13c58a (patch)
tree7d1ea603194b98d213c3f90253371ef974f8ee0f /src/vsession.cpp
parentAdded httpxmldownloader (diff)
downloadvmchooser2-03b7858c880ea1fba3915af17c55b42d5e13c58a.tar.gz
vmchooser2-03b7858c880ea1fba3915af17c55b42d5e13c58a.tar.xz
vmchooser2-03b7858c880ea1fba3915af17c55b42d5e13c58a.zip
- included the --url commandline options for a xml url
- httpxmldownloader moved to main.cpp (it's finally working :D) - given url is downloaded and printed on commandline - todo: parse http response
Diffstat (limited to 'src/vsession.cpp')
-rw-r--r--src/vsession.cpp51
1 files changed, 51 insertions, 0 deletions
diff --git a/src/vsession.cpp b/src/vsession.cpp
index 9800908..7e41b51 100644
--- a/src/vsession.cpp
+++ b/src/vsession.cpp
@@ -3,6 +3,7 @@
#include <QApplication>
#include <QProcess>
#include <QDate>
+#include <QThread>
#include <QStringList>
#if 0
#include <QHostInfo> // available since Qt 4.7
@@ -13,6 +14,7 @@
#include <pwd.h> // for getpwuid
#include "globals.h"
#include "vsession.h"
+#include "httpxmldownloader.h"
bool VSession::init(const QString& xml, const QString& baseDirPath) {
this->baseDirPath_ = baseDirPath;
@@ -298,6 +300,55 @@ int VSession::type() const {
return Session::VSESSION;
}
+QList<Session*> VSession::readXmlUrl(const QString& xmlurl, httpxmldownloader& httpxmldownloader) {
+ QList<Session*> retval;
+
+ // create thread
+ //QThread thread;
+
+ QNetworkReply* reply = httpxmldownloader.makeRequest(xmlurl);
+
+ if (reply->isFinished()) {}
+
+// for (int i = 0; i < 5; i++) {
+// qDebug() << reply->isRunning();
+// sleep(1);
+// }
+//
+// //downloader.moveToThread(&thread);
+// //thread.start();
+//
+//
+// if (debugMode) {
+// qDebug() << "Made http request with: " << xmlurl;
+// }
+//
+// QDomDocument doc;
+//
+// QString xml_doc(reply->readAll());
+//
+// if (!doc.setContent(QString(reply->readAll()))) {
+// // error in xml, return emtpy list
+// return retval;
+// }
+
+// // TODO: what dirName??#
+// // copied from readXmlFile(...)
+// QString dirName = "/loaded/from/url";
+// QDomElement settingsNode = doc.firstChildElement("settings");
+// for (QDomElement el(settingsNode.firstChildElement("eintrag"));
+// !el.isNull();
+// el = el.nextSiblingElement("eintrag")) {
+// QDomDocument dummy;
+// dummy.appendChild(dummy.importNode(el, true));
+// VSession* e = new VSession;
+// if (e->init(dummy.toString(), dirName)) {
+// retval.append(e);
+// }
+// }
+ return retval;
+}
+
QList<Session*> VSession::readXmlFile(const QString& filepath) {
QList<Session*> retval;