Pull Request fixes

This commit is contained in:
Leonardo Murillo 2014-01-18 20:17:47 -06:00
parent 865045aae7
commit cd9f2fd240
4 changed files with 36 additions and 43 deletions

View file

@ -95,6 +95,7 @@ const float MIRROR_REARVIEW_DISTANCE = 0.65f;
const float MIRROR_REARVIEW_BODY_DISTANCE = 2.3f;
const QString CHECK_VERSION_URL = "http://highfidelity.io/latestVersion.xml";
const QString SKIP_FILENAME = QStandardPaths::writableLocation(QStandardPaths::DataLocation) + "/hifi.skipversion";
void messageHandler(QtMsgType type, const QMessageLogContext& context, const QString &message) {
QString messageWithNewLine = message + "\n";
@ -202,8 +203,6 @@ 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);
@ -262,7 +261,8 @@ Application::Application(int& argc, char** argv, timeval &startup_time) :
// Set the sixense filtering
_sixenseManager.setFilter(Menu::getInstance()->isOptionChecked(MenuOption::FilterSixense));
checkVersion();
}
Application::~Application() {
@ -4367,31 +4367,28 @@ void Application::updateLocalOctreeCache(bool firstTime) {
void Application::checkVersion() {
QUrl url(CHECK_VERSION_URL);
QNetworkAccessManager *downloadXML = new QNetworkAccessManager(this);
QNetworkRequest request(url);
connect(downloadXML, SIGNAL(finished(QNetworkReply*)), this, SLOT(parseVersionXml(QNetworkReply*)));
downloadXML->get(request);
QNetworkRequest latestVersionRequest(url);
latestVersionRequest.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
_latestVersionReply = getNetworkAccessManager()->get(latestVersionRequest);
connect(_latestVersionReply, SIGNAL(readyRead()), SLOT(parseVersionXml()));
}
void Application::parseVersionXml(QNetworkReply *reply) {
QString *operatingSystem;
void Application::parseVersionXml() {
#ifdef Q_OS_WIN32
operatingSystem = new QString("win");
QString operatingSystem("win");
#endif
#ifdef Q_OS_MAC
operatingSystem = new QString("mac");
QString operatingSystem("mac");
#endif
QString releaseDate;
QString releaseNotes;
QString latestVersion;
QUrl downloadURL;
QWidget *updateDialog;
QXmlStreamReader xml(reply);
QXmlStreamReader xml(_latestVersionReply);
while (!xml.atEnd() && !xml.hasError()) {
QXmlStreamReader::TokenType token = xml.readNext();
@ -4410,36 +4407,28 @@ void Application::parseVersionXml(QNetworkReply *reply) {
}
if (xml.name() == operatingSystem) {
xml.readNext();
downloadURL = QUrl(xml.text().toString());
_downloadUrl = QUrl(xml.text().toString());
}
}
}
if (!shouldSkipVersion(latestVersion) && applicationVersion() != latestVersion) {
updateDialog = new UpdateDialog(_glWidget, releaseNotes, latestVersion, downloadURL);
new UpdateDialog(_glWidget, releaseNotes, latestVersion, _downloadUrl);
}
delete _latestVersionReply;
}
bool Application::shouldSkipVersion(QString latestVersion) {
QString fileName = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
fileName.append(QString("/hifi.skipversion"));
QFile skipFile(fileName);
QFile skipFile(SKIP_FILENAME);
skipFile.open(QIODevice::ReadWrite);
QByteArray skipFileContents = skipFile.readAll();
QString skipVersion(skipFileContents);
skipFile.close();
if (skipVersion == latestVersion || applicationVersion() == "dev") {
return true;
}
return false;
QString skipVersion(skipFile.readAll());
return (skipVersion == latestVersion /*|| applicationVersion() == "dev"*/);
}
void Application::skipVersion(QString latestVersion) {
QString fileName = QStandardPaths::writableLocation(QStandardPaths::DataLocation);
fileName.append(QString("/hifi.skipversion"));
QFile skipFile(fileName);
QFile skipFile(SKIP_FILENAME);
skipFile.open(QIODevice::WriteOnly|QIODevice::Truncate);
skipFile.seek(0);
skipFile.write(latestVersion.toStdString().c_str());
skipFile.close();
}

View file

@ -203,6 +203,8 @@ 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; }
QUrl _downloadUrl;
public slots:
void domainChanged(const QString& domainHostname);
@ -251,7 +253,7 @@ private slots:
void shrinkMirrorView();
void resetSensors();
void parseVersionXml(QNetworkReply *reply);
void parseVersionXml();
private:
void resetCamerasOnResizeGL(Camera& camera, int width, int height);
@ -503,6 +505,7 @@ private:
void displayUpdateDialog();
bool shouldSkipVersion(QString latestVersion);
void skipVersion(QString latestVersion);
QNetworkReply* _latestVersionReply;
};
#endif /* defined(__interface__Application__) */

View file

@ -19,17 +19,18 @@
#include "SharedUtil.h"
#include "UpdateDialog.h"
UpdateDialog::UpdateDialog(QWidget *parent, QString releaseNotes, QString latestVersion, QUrl downloadURL) : QDialog(parent, Qt::Dialog) {
UpdateDialog::UpdateDialog(QWidget *parent, QString releaseNotes, QString latestVersion, QUrl downloadURL) :
QDialog(parent, Qt::Dialog) {
Application* application = Application::getInstance();
QUiLoader updateDialogLoader;
QFile updateDialogUi("resources/ui/updateDialog.ui");
updateDialogUi.open(QFile::ReadOnly);
_dialogWidget = updateDialogLoader.load(&updateDialogUi, parent);
updateDialogUi.close();
_dialogWidget = updateDialogLoader.load(&updateDialogUi, this);
const QString updateRequired = QString("You are currently running build %1, the latest build released is %2. \
QString updateRequired = QString("You are currently running build %1, the latest build released is %2. \
Please download and install the most recent release to access the latest features and bug fixes.")
.arg(application->applicationVersion(), latestVersion);
@ -43,22 +44,22 @@ UpdateDialog::UpdateDialog(QWidget *parent, QString releaseNotes, QString latest
updateContent->setText(updateRequired);
connect(downloadButton, SIGNAL(released()), this, SLOT(handleDownload(QUrl downloadURL)));
connect(downloadButton, SIGNAL(released()), this, SLOT(handleDownload()));
connect(skipButton, SIGNAL(released()), this, SLOT(handleSkip()));
connect(closeButton, SIGNAL(released()), this, SLOT(handleClose()));
_dialogWidget->show();
}
void UpdateDialog::handleDownload(QUrl downloadURL) {
void UpdateDialog::handleDownload() {
Application* application = Application::getInstance();
QDesktopServices::openUrl(downloadURL);
QDesktopServices::openUrl(application->_downloadUrl);
application->quit();
}
void UpdateDialog::handleSkip() {
this->_dialogWidget->close();
this->close();
}
void UpdateDialog::handleClose() {
this->_dialogWidget->close();
this->close();
}

View file

@ -18,13 +18,13 @@ class UpdateDialog : public QDialog {
Q_OBJECT
public:
UpdateDialog(QWidget*, QString releaseNotes, QString latestVersion, QUrl downloadURL);
UpdateDialog(QWidget* parent, QString releaseNotes, QString latestVersion, QUrl downloadURL);
private:
QWidget* _dialogWidget;
private slots:
void handleDownload(QUrl downloadURL);
void handleDownload();
void handleSkip();
void handleClose();
};