diff options
author | Nils Schwabe | 2014-03-03 18:11:34 +0100 |
---|---|---|
committer | Nils Schwabe | 2014-03-03 18:11:34 +0100 |
commit | fc65962bd64b0e4972eeef1d325c39c51781e9f8 (patch) | |
tree | 308e2cc3931d97e4aed2ae0ec6a0e61c9df3b668 | |
parent | added files from vmchooser1 (diff) | |
download | vmchooser2-fc65962bd64b0e4972eeef1d325c39c51781e9f8.tar.gz vmchooser2-fc65962bd64b0e4972eeef1d325c39c51781e9f8.tar.xz vmchooser2-fc65962bd64b0e4972eeef1d325c39c51781e9f8.zip |
Added httpxmldownloader
-rw-r--r-- | CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/httpxmldownloader.cpp | 24 | ||||
-rw-r--r-- | src/httpxmldownloader.h | 19 | ||||
-rw-r--r-- | src/main.cpp | 6 | ||||
-rw-r--r-- | src/vsession.cpp | 2 |
5 files changed, 52 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 4f6ca9c..8fcb0d2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,6 +27,7 @@ endif(QT4_FOUND) set(QT_USE_QTXML TRUE) set(QT_USE_QTSVG TRUE) +set(QT_USE_QTNETWORK TRUE) include(${QT_USE_FILE}) diff --git a/src/httpxmldownloader.cpp b/src/httpxmldownloader.cpp new file mode 100644 index 0000000..4474b9d --- /dev/null +++ b/src/httpxmldownloader.cpp @@ -0,0 +1,24 @@ + +#include "httpxmldownloader.h" +#include <QDebug> + +httpxmldownloader::httpxmldownloader() { + nam = new QNetworkAccessManager(this); + QObject::connect(nam, SIGNAL(finished(QNetworkReply*)), + this, SLOT(finishedSlot(QNetworkReply*))); + + QString url_string = "http://localhost/test.xml"; + + QUrl url(url_string); + nam->get(QNetworkRequest(url)); +} + +void httpxmldownloader::finishedSlot(QNetworkReply* reply) { + // no errors received + if (reply->error() == QNetworkReply::NoError) { + QString xml_doc(reply->readAll()); + qDebug() << xml_doc; + } else { + qDebug() << "Error reading from URL: " << reply->error(); + } +} diff --git a/src/httpxmldownloader.h b/src/httpxmldownloader.h new file mode 100644 index 0000000..7bdaf56 --- /dev/null +++ b/src/httpxmldownloader.h @@ -0,0 +1,19 @@ + +#ifndef HTTPTEST_H_ +#define HTTPTEST_H_ + +#include <QNetworkAccessManager> +#include <QUrl> +#include <QNetworkRequest> +#include <QNetworkReply> + +class httpxmldownloader : public QObject { + Q_OBJECT + QNetworkAccessManager* nam; +public: + httpxmldownloader(); +private slots: + void finishedSlot(QNetworkReply*); +}; + +#endif /* HTTPTEST_H_ */ diff --git a/src/main.cpp b/src/main.cpp index 8ccbba2..d1b0ace 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -18,6 +18,7 @@ #include "save_restore_session.h" #include "vsession.h" #include "xsession.h" +#include "httpxmldownloader.h" bool myLessThan(Session* a, Session* b) { return *a < *b; @@ -50,6 +51,11 @@ int main(int argc, char *argv[]) { "\nFILE can be a vmware .xml or an X .desktop file\n") .toUtf8().data()); + // --------- + std::cout << "testing http" << std::endl; + httpxmldownloader httpxmldownloader; + // --------- + if (cmdOptions.contains("error")) { std::cerr << usage; return EXIT_FAILURE; diff --git a/src/vsession.cpp b/src/vsession.cpp index e9059f2..9800908 100644 --- a/src/vsession.cpp +++ b/src/vsession.cpp @@ -385,6 +385,8 @@ QList<Session*> VSession::readXmlDir(const QString& path) { continue; } + if (debugMode) qDebug() << "added " << vsessionTmp.first()->shortDescription() << " to list"; + retval.append(vsessionTmp); } } |