summaryrefslogtreecommitdiffstats
path: root/src/vsession.cpp
diff options
context:
space:
mode:
authorNils Schwabe2014-03-06 16:02:08 +0100
committerNils Schwabe2014-03-06 16:02:08 +0100
commitb1117bb9e31018460b5adc05428842555d47c1b9 (patch)
treec472454b3e795bf2a3712899653a5d166dfb8645 /src/vsession.cpp
parent- included the --url commandline options for a xml url (diff)
downloadvmchooser2-b1117bb9e31018460b5adc05428842555d47c1b9.tar.gz
vmchooser2-b1117bb9e31018460b5adc05428842555d47c1b9.tar.xz
vmchooser2-b1117bb9e31018460b5adc05428842555d47c1b9.zip
vmchooser is now able to get vsessions from a given url
Diffstat (limited to 'src/vsession.cpp')
-rw-r--r--src/vsession.cpp61
1 files changed, 8 insertions, 53 deletions
diff --git a/src/vsession.cpp b/src/vsession.cpp
index 7e41b51..8134bc6 100644
--- a/src/vsession.cpp
+++ b/src/vsession.cpp
@@ -300,66 +300,21 @@ 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;
QDomDocument doc;
QFile file(filepath);
if (!file.open(QIODevice::ReadOnly)) {
- // TODO: error message
+ if (debugMode) {
+ qDebug() << "Cannot read file: " << file.fileName();
+ }
return retval;
}
if (!doc.setContent(&file)) {
- // TODO: error message
+ if (debugMode) {
+ qDebug() << "XML file not valid: " << file.fileName();
+ }
file.close();
return retval;
}
@@ -368,8 +323,8 @@ QList<Session*> VSession::readXmlFile(const QString& filepath) {
QString dirName(QFileInfo(filepath).dir().absolutePath());
QDomElement settingsNode = doc.firstChildElement("settings");
for (QDomElement el(settingsNode.firstChildElement("eintrag"));
- !el.isNull();
- el = el.nextSiblingElement("eintrag")) {
+ !el.isNull();
+ el = el.nextSiblingElement("eintrag")) {
QDomDocument dummy;
dummy.appendChild(dummy.importNode(el, true));
VSession* e = new VSession;