From d44126ac33c65bafb270b15c8f29724e23141e40 Mon Sep 17 00:00:00 2001 From: Leonardo Murillo Date: Wed, 8 Jan 2014 08:30:50 -0600 Subject: [PATCH] Get version XML and store latest version as application property --- interface/CMakeLists.txt | 3 ++- interface/src/Application.cpp | 41 +++++++++++++++++++++++++++++++++++ interface/src/Application.h | 9 ++++++++ 3 files changed, 52 insertions(+), 1 deletion(-) diff --git a/interface/CMakeLists.txt b/interface/CMakeLists.txt index ecc6ff79cb..ccc26b630a 100644 --- a/interface/CMakeLists.txt +++ b/interface/CMakeLists.txt @@ -60,6 +60,7 @@ find_package(Qt5OpenGL REQUIRED) find_package(Qt5Svg REQUIRED) find_package(Qt5WebKit REQUIRED) find_package(Qt5WebKitWidgets REQUIRED) +find_package(Qt5Xml REQUIRED) if (APPLE) set(MACOSX_BUNDLE_BUNDLE_NAME Interface) @@ -136,7 +137,7 @@ if (LIBOVR_FOUND AND NOT DISABLE_LIBOVR) target_link_libraries(${TARGET_NAME} ${LIBOVR_LIBRARIES}) endif (LIBOVR_FOUND AND NOT DISABLE_LIBOVR) -qt5_use_modules(${TARGET_NAME} Core Gui Multimedia Network OpenGL Script Svg WebKit WebKitWidgets) +qt5_use_modules(${TARGET_NAME} Core Gui Multimedia Network OpenGL Script Svg WebKit WebKitWidgets Xml) # include headers for interface and InterfaceConfig. include_directories( diff --git a/interface/src/Application.cpp b/interface/src/Application.cpp index 6df74a47d5..1cdef9f0fe 100644 --- a/interface/src/Application.cpp +++ b/interface/src/Application.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include #include #include @@ -37,6 +38,8 @@ #include #include #include +#include +#include #include #include @@ -192,6 +195,8 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : setOrganizationName(applicationInfo.value("organizationName").toString()); setOrganizationDomain(applicationInfo.value("organizationDomain").toString()); + checkVersion(); + qDebug("[VERSION] Build sequence: %s\n", applicationVersion().toStdString().c_str()); _settings = new QSettings(this); @@ -4536,3 +4541,39 @@ void Application::toggleLogDialog() { _logDialog->close(); } } + +void Application::loadLatestVersionDetails() { + QUrl url("https://a-tower.below92.com/version.xml"); + QNetworkAccessManager *downloadXML = new QNetworkAccessManager(this); + QNetworkRequest request(url); + connect(downloadXML, SIGNAL(finished(QNetworkReply*)), this, SLOT(parseVersionXml(QNetworkReply*))); + downloadXML->get(request); + +} + +void Application::parseVersionXml(QNetworkReply *reply) { + QXmlStreamReader xml(reply); + while (!xml.atEnd() && !xml.hasError()) { + QXmlStreamReader::TokenType token = xml.readNext(); + + if (token == QXmlStreamReader::StartElement) { + if (xml.name() == "Version") { + xml.readNext(); + _latestVersion = xml.text().toString(); + qDebug("################ Version found %s\n", _latestVersion.toStdString().c_str()); + } + } + + } +} + +void Application::checkVersion() { + loadLatestVersionDetails(); + + // This is a very rudimentary check, if this version is not equal to latest then you need to get it + // unless you're coming from the future. + + //if (applicationVersion() != 0 && applicationVersion() != this->_latestVersion) { + + //} +} diff --git a/interface/src/Application.h b/interface/src/Application.h index 6f0463bc88..a02f136d3d 100644 --- a/interface/src/Application.h +++ b/interface/src/Application.h @@ -212,6 +212,11 @@ public: /// set a voxel which is to be rendered with a highlight void setHighlightVoxel(const VoxelDetail& highlightVoxel) { _highlightVoxel = highlightVoxel; } void setIsHighlightVoxel(bool isHighlightVoxel) { _isHighlightVoxel = isHighlightVoxel; } + + // Get XML with version information and parse it + // Display dialog when version is not the latest and allow for new version download from link + void loadLatestVersionDetails(); + void checkVersion(); public slots: void sendAvatarFaceVideoMessage(int frameCount, const QByteArray& data); @@ -255,6 +260,8 @@ private slots: void restoreMirrorView(); void shrinkMirrorView(); void resetSensors(); + + void parseVersionXml(QNetworkReply *reply); private: void resetCamerasOnResizeGL(Camera& camera, int width, int height); @@ -512,6 +519,8 @@ private: QPointer _logDialog; FileLogger* _logger; + + QString _latestVersion; }; #endif /* defined(__interface__Application__) */