From 03b7858c880ea1fba3915af17c55b42d5e13c58a Mon Sep 17 00:00:00 2001 From: Nils Schwabe Date: Tue, 4 Mar 2014 17:54:57 +0100 Subject: - 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 --- src/vsession.cpp | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) (limited to 'src/vsession.cpp') 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 #include #include +#include #include #if 0 #include // available since Qt 4.7 @@ -13,6 +14,7 @@ #include // 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 VSession::readXmlUrl(const QString& xmlurl, httpxmldownloader& httpxmldownloader) { + QList 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 VSession::readXmlFile(const QString& filepath) { QList retval; -- cgit v1.2.3-55-g7522