Skip to content

Commit

Permalink
Download new version over HTTPS
Browse files Browse the repository at this point in the history
  • Loading branch information
mistic100 committed Feb 5, 2017
1 parent 4d66afd commit 12fbe05
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 4 deletions.
2 changes: 2 additions & 0 deletions installer/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ Put these files in `data` directory before running `setup.iss` or `package.bat`:
* Qt5Network.dll
* Qt5Widgets.dll
* Qt5Xml.dll
* libeay32.dll
* ssleay32.dll
* imageformats/qgif.dll
* imageformats/qjpeg.dll
* platforms/qwindows.dll
Expand Down
2 changes: 1 addition & 1 deletion src/constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@

#define APP_HOMEPAGE "https://www.strangeplanet.fr/work/umwp-autochanger"
#define APP_DOCUMENTATION_URL "https://www.strangeplanet.fr/work/umwp-autochanger/#help"
#define APP_VERSION_URL "http://www.strangeplanet.fr/work/umwp-autochanger/last-version.txt"
#define APP_VERSION_URL "https://www.strangeplanet.fr/work/umwp-autochanger/last-version.txt"
#define APP_ISSUES_URL "https://github.com/mistic100/UMWP-Autochanger/issues"

#define APP_INSTALLER_SIZE 12000000
Expand Down
11 changes: 9 additions & 2 deletions src/gui/newversiondialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,14 @@ void NewVersionDialog::on_updateButton_clicked()
QLOG_DEBUG() << "Download" << m_version.link;

QNetworkAccessManager* manager = new QNetworkAccessManager();
m_reply = manager->get(QNetworkRequest(QUrl(m_version.link)));

QNetworkRequest request(QUrl(m_version.link));
if (m_version.link.startsWith("https"))
{
request.setSslConfiguration(QSslConfiguration::defaultConfiguration());
}

m_reply = manager->get(request);

connect(m_reply, SIGNAL(readyRead()), this, SLOT(onDataReady()));
connect(m_reply, SIGNAL(finished()), this, SLOT(onDownloadFinished()));
Expand Down Expand Up @@ -114,7 +121,7 @@ void NewVersionDialog::onDownloadFinished()

if (m_reply->error() != QNetworkReply::NoError)
{
QLOG_ERROR() << "Network error";
QLOG_ERROR() << m_reply->errorString();

m_file.remove();
errorMessage();
Expand Down
17 changes: 16 additions & 1 deletion src/versionchecker.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,14 @@ public slots:
{
QNetworkAccessManager* manager = new QNetworkAccessManager();
connect(manager, SIGNAL(finished(QNetworkReply*)), this, SLOT(downloadFinished(QNetworkReply*)));
manager->get(QNetworkRequest(QUrl(APP_VERSION_URL)));

QNetworkRequest request(QUrl(APP_VERSION_URL));
if (QString(APP_VERSION_URL).startsWith("https"))
{
request.setSslConfiguration(QSslConfiguration::defaultConfiguration());
}

manager->get(request);
}

private slots:
Expand All @@ -35,13 +42,21 @@ private slots:
version.code = _reply->readLine().trimmed();
version.link = _reply->readLine().trimmed();
version.hash = _reply->readLine().trimmed();
if (QString(APP_VERSION_URL).startsWith("https"))
{
version.link = version.link.replace("http://", "https://");
}

if (version.code.compare(APP_VERSION) > 0)
{
QLOG_DEBUG() << "New version detected: " << version.code;
emit newVersionAvailable(version);
}
}
else
{
QLOG_ERROR() << _reply->errorString();
}

_reply->manager()->deleteLater();
_reply->deleteLater();
Expand Down

0 comments on commit 12fbe05

Please sign in to comment.