summaryrefslogtreecommitdiffstats
path: root/src/dialog.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/dialog.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/dialog.cpp')
-rw-r--r--src/dialog.cpp28
1 files changed, 28 insertions, 0 deletions
diff --git a/src/dialog.cpp b/src/dialog.cpp
index d758b0a..def152c 100644
--- a/src/dialog.cpp
+++ b/src/dialog.cpp
@@ -12,6 +12,7 @@
#include "save_restore_session.h"
#include "sessiontreeitem.h"
#include "globals.h"
+#include "vsession.h"
Dialog::Dialog(QWidget *parent)
: QDialog(parent), ui(new Ui::Dialog) {
@@ -246,3 +247,30 @@ void Dialog::on_centerTimer() {
}
}
+void Dialog::addSessionsAfterDownload(QNetworkReply* reply) {
+ if (reply->error() != QNetworkReply::NoError) {
+ qDebug() << "Error reading from URL: " << reply->error();
+ return;
+ }
+
+ QString xml_doc(reply->readAll());
+
+ QFile file("/tmp/vmchooser2.xml");
+ if (!file.open(QIODevice::WriteOnly)) {
+ if (debugMode) {
+ qDebug() << "Could not write XML to /tmp";
+ }
+ return;
+ }
+
+ QByteArray data = xml_doc.toUtf8();
+
+ if (file.write(data) != data.length()) {
+ return;
+ }
+
+ file.close();
+
+ this->addItems(VSession::readXmlFile(file.fileName()), QCoreApplication::instance()->translate("Dialog", "Virtual Sessions"));
+}
+