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