Showing the changes to interface/src/Application.cpp (1 of 4 files). Show all
Unified · Split
| @@ -95,6 +95,7 @@ const float MIRROR_REARVIEW_DISTANCE = 0.65f; · 94 unmodified lines | ||
| 95 | 95 | const float MIRROR_REARVIEW_BODY_DISTANCE = 2.3f; |
| 96 | 96 | |
| 97 | 97 | const QString CHECK_VERSION_URL = "http://highfidelity.io/latestVersion.xml"; |
| 98 | +const QString SKIP_FILENAME = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/hifi.skipversion"; | |
| 98 | 99 | |
| 99 | 100 | void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString &message) { |
| 100 | 101 | QString messageWithNewLine = message + "\n"; |
| @@ -202,8 +203,6 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 101 unmodified lines | ||
| 202 | 203 | setOrganizationName(applicationInfo.value("organizationName").toString()); |
| 203 | 204 | setOrganizationDomain(applicationInfo.value("organizationDomain").toString()); |
| 204 | 205 | |
| 205 | − checkVersion(); | |
| 206 | − | |
| 207 | 206 | qDebug("[VERSION] Build sequence: %s\n", applicationVersion().toStdString().c_str()); |
| 208 | 207 | |
| 209 | 208 | _settings = new QSettings(this); |
| @@ -262,7 +261,8 @@ Application::Application(int& argc, char** argv, timeval &startup_time) : · 52 unmodified lines | ||
| 262 | 261 | |
| 263 | 262 | // Set the sixense filtering |
| 264 | 263 | _sixenseManager.setFilter(Menu::getInstance()->isOptionChecked(MenuOption::FilterSixense)); |
| 265 | − | |
| 264 | + | |
| 265 | + checkVersion(); | |
| 266 | 266 | } |
| 267 | 267 | |
| 268 | 268 | Application::~Application() { |
| @@ -4367,31 +4367,28 @@ void Application::updateLocalOctreeCache(bool firstTime) { · 4098 unmodified lines | ||
| 4367 | 4367 | |
| 4368 | 4368 | void Application::checkVersion() { |
| 4369 | 4369 | QUrl url(CHECK_VERSION_URL); |
| 4370 | − QNetworkAccessManager *downloadXML = new QNetworkAccessManager(this); | |
| 4371 | − QNetworkRequest request(url); | |
| 4372 | − connect(downloadXML, SIGNAL(finished(QNetworkReply*)), this, SLOT(parseVersionXml(QNetworkReply*))); | |
| 4373 | − downloadXML->get(request); | |
| 4370 | + QNetworkRequest latestVersionRequest(url); | |
| 4371 | + latestVersionRequest.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache); | |
| 4372 | + _latestVersionReply = getNetworkAccessManager()->get(latestVersionRequest); | |
| 4373 | + | |
| 4374 | + connect(_latestVersionReply, SIGNAL(readyRead()), SLOT(parseVersionXml())); | |
| 4374 | 4375 | } |
| 4375 | 4376 | |
| 4376 | −void Application::parseVersionXml(QNetworkReply *reply) { | |
| 4377 | − QString *operatingSystem; | |
| 4377 | +void Application::parseVersionXml() { | |
| 4378 | 4378 | |
| 4379 | 4379 | #ifdef Q_OS_WIN32 |
| 4380 | − operatingSystem = new QString("win"); | |
| 4380 | + QString operatingSystem("win"); | |
| 4381 | 4381 | #endif |
| 4382 | 4382 | |
| 4383 | 4383 | #ifdef Q_OS_MAC |
| 4384 | − operatingSystem = new QString("mac"); | |
| 4384 | + QString operatingSystem("mac"); | |
| 4385 | 4385 | #endif |
| 4386 | 4386 | |
| 4387 | 4387 | QString releaseDate; |
| 4388 | 4388 | QString releaseNotes; |
| 4389 | 4389 | QString latestVersion; |
| 4390 | − QUrl downloadURL; | |
| 4391 | − | |
| 4392 | − QWidget *updateDialog; | |
| 4393 | 4390 | |
| 4394 | − QXmlStreamReader xml(reply); | |
| 4391 | + QXmlStreamReader xml(_latestVersionReply); | |
| 4395 | 4392 | while (!xml.atEnd() && !xml.hasError()) { |
| 4396 | 4393 | QXmlStreamReader::TokenType token = xml.readNext(); |
| 4397 | 4394 | |
| @@ -4410,36 +4407,28 @@ void Application::parseVersionXml(QNetworkReply *reply) { · 12 unmodified lines | ||
| 4410 | 4407 | } |
| 4411 | 4408 | if (xml.name() == operatingSystem) { |
| 4412 | 4409 | xml.readNext(); |
| 4413 | − downloadURL = QUrl(xml.text().toString()); | |
| 4410 | + _downloadUrl = QUrl(xml.text().toString()); | |
| 4414 | 4411 | } |
| 4415 | 4412 | } |
| 4416 | 4413 | } |
| 4417 | 4414 | |
| 4418 | 4415 | if (!shouldSkipVersion(latestVersion) && applicationVersion() != latestVersion) { |
| 4419 | − updateDialog = new UpdateDialog(_glWidget, releaseNotes, latestVersion, downloadURL); | |
| 4416 | + new UpdateDialog(_glWidget, releaseNotes, latestVersion, _downloadUrl); | |
| 4420 | 4417 | } |
| 4418 | + | |
| 4419 | + delete _latestVersionReply; | |
| 4421 | 4420 | } |
| 4422 | 4421 | |
| 4423 | 4422 | bool Application::shouldSkipVersion(QString latestVersion) { |
| 4424 | − QString fileName = QStandardPaths::writableLocation(QStandardPaths::DataLocation); | |
| 4425 | − fileName.append(QString("/hifi.skipversion")); | |
| 4426 | − QFile skipFile(fileName); | |
| 4423 | + QFile skipFile(SKIP_FILENAME); | |
| 4427 | 4424 | skipFile.open(QIODevice::ReadWrite); |
| 4428 | − QByteArray skipFileContents = skipFile.readAll(); | |
| 4429 | − QString skipVersion(skipFileContents); | |
| 4430 | − skipFile.close(); | |
| 4431 | − if (skipVersion == latestVersion || applicationVersion() == "dev") { | |
| 4432 | − return true; | |
| 4433 | − } | |
| 4434 | − return false; | |
| 4425 | + QString skipVersion(skipFile.readAll()); | |
| 4426 | + return (skipVersion == latestVersion /*|| applicationVersion() == "dev"*/); | |
| 4435 | 4427 | } |
| 4436 | 4428 | |
| 4437 | 4429 | void Application::skipVersion(QString latestVersion) { |
| 4438 | − QString fileName = QStandardPaths::writableLocation(QStandardPaths::DataLocation); | |
| 4439 | − fileName.append(QString("/hifi.skipversion")); | |
| 4440 | − QFile skipFile(fileName); | |
| 4430 | + QFile skipFile(SKIP_FILENAME); | |
| 4441 | 4431 | skipFile.open(QIODevice::WriteOnly|QIODevice::Truncate); |
| 4442 | 4432 | skipFile.seek(0); |
| 4443 | 4433 | skipFile.write(latestVersion.toStdString().c_str()); |
| 4444 | − skipFile.close(); | |
| 4445 | 4434 | } |