Blame toonz/sources/toonzqt/updatechecker.cpp
|
Toshihiro Shimizu |
890ddd |
#include "./toonzqt/updatechecker.h"
|
|
Toshihiro Shimizu |
890ddd |
#include <qnetworkreply></qnetworkreply>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
7be7e6 |
UpdateChecker::UpdateChecker(QUrl const& updateUrl)
|
|
Shinya Kitaoka |
120a6e |
: manager_(new QNetworkAccessManager(this),
|
|
Shinya Kitaoka |
120a6e |
&QNetworkAccessManager::deleteLater) {
|
|
Shinya Kitaoka |
120a6e |
connect(manager_.data(), SIGNAL(finished(QNetworkReply*)), this,
|
|
Shinya Kitaoka |
120a6e |
SLOT(httpRequestFinished(QNetworkReply*)));
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
manager_->get(QNetworkRequest(updateUrl));
|
|
Toshihiro Shimizu |
890ddd |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
void UpdateChecker::httpRequestFinished(QNetworkReply* pReply) {
|
|
Shinya Kitaoka |
120a6e |
QSharedPointer<qnetworkreply> reply(pReply, &QNetworkReply::deleteLater);</qnetworkreply>
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (reply->error() != QNetworkReply::NoError) {
|
|
Shinya Kitaoka |
120a6e |
emit done(true);
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
QString candidateVersion = QString(reply->readAll()).trimmed();
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
if (candidateVersion.indexOf(".") < 0) {
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
emit done(true);
|
|
Shinya Kitaoka |
120a6e |
return;
|
|
Shinya Kitaoka |
120a6e |
}
|
|
Toshihiro Shimizu |
890ddd |
|
|
Shinya Kitaoka |
120a6e |
|
|
Shinya Kitaoka |
120a6e |
m_latestVersion = candidateVersion;
|
|
Shinya Kitaoka |
120a6e |
emit done(false);
|
|
Toshihiro Shimizu |
890ddd |
}
|