Fixed compilation issues with Android
This commit is contained in:
parent
0a7107c414
commit
9ecad33138
@ -18,7 +18,7 @@ OTHER_FILES += $$PWD/src/QSimpleUpdater
|
|||||||
|
|
||||||
INCLUDEPATH += $$PWD/src
|
INCLUDEPATH += $$PWD/src
|
||||||
|
|
||||||
macx || linux{
|
macx || linux:!android {
|
||||||
LIBS += -lcrypto -lssl
|
LIBS += -lcrypto -lssl
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,31 +1,31 @@
|
|||||||
--------------
|
--------------
|
||||||
PREFACE
|
PREFACE
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
Many websites today use the HTTPS protocol, which means that you will need SSL in order to communicate with them. If your project needs to access such a webiste (for example GitHub), you will need to carefully read the following information in order to ensure that QSimpleUpdater works with those websites (both in your machine and in the final users' machine).
|
Many websites today use the HTTPS protocol, which means that you will need SSL in order to communicate with them. If your project needs to access such a webiste (for example GitHub), you will need to carefully read the following information in order to ensure that QSimpleUpdater works with those websites (both in your machine and in the final users' machine).
|
||||||
|
|
||||||
This readme guide is extremely important for any developer wishing to deploy his or her applications under the Windows platform, because the application will depend on the libraries provided by QSimpleUpdater.
|
This readme guide is extremely important for any developer wishing to deploy his or her applications under the Windows platform, because the application will depend on the libraries provided by QSimpleUpdater.
|
||||||
|
|
||||||
--------------
|
--------------
|
||||||
LINUX
|
LINUX
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
Make sure that you have installed the following libraries in your system:
|
Make sure that you have installed the following libraries in your system:
|
||||||
|
|
||||||
- lssl
|
- lssl
|
||||||
- lcrypto
|
- lcrypto
|
||||||
|
|
||||||
--------------
|
--------------
|
||||||
MAC OSX
|
MAC OSX
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
The libraries required by QSimpleUpdater are the same as Linux, however, these libraries are installed by default in most Mac OS X installations.
|
The libraries required by QSimpleUpdater are the same as Linux, however, these libraries are installed by default in most Mac OS X installations.
|
||||||
|
|
||||||
--------------
|
--------------
|
||||||
WINDOWS
|
WINDOWS
|
||||||
--------------
|
--------------
|
||||||
|
|
||||||
QSimpleUpdater makes use of the OpenSSL-Win32 project, make sure that you deploy the following DLLs allong your application (the DLLs are provided with the source of QSimpleUpdater):
|
QSimpleUpdater makes use of the OpenSSL-Win32 project, make sure that you deploy the following DLLs allong your application (the DLLs are provided with the source of QSimpleUpdater):
|
||||||
|
|
||||||
- dependencies/OpenSSL-Win32/bin/libeay32.dll
|
- dependencies/OpenSSL-Win32/bin/libeay32.dll
|
||||||
- dependencies/OpenSSL-Win32/bin/ssleay32.dll
|
- dependencies/OpenSSL-Win32/bin/ssleay32.dll
|
@ -11,8 +11,7 @@
|
|||||||
|
|
||||||
DownloadDialog::DownloadDialog (QWidget *parent) :
|
DownloadDialog::DownloadDialog (QWidget *parent) :
|
||||||
QWidget (parent),
|
QWidget (parent),
|
||||||
ui (new Ui::DownloadDialog)
|
ui (new Ui::DownloadDialog) {
|
||||||
{
|
|
||||||
// Setup the UI
|
// Setup the UI
|
||||||
ui->setupUi (this);
|
ui->setupUi (this);
|
||||||
|
|
||||||
@ -27,13 +26,11 @@ DownloadDialog::DownloadDialog (QWidget *parent) :
|
|||||||
this, SLOT (ignoreSslErrors (QNetworkReply *, QList<QSslError>)));
|
this, SLOT (ignoreSslErrors (QNetworkReply *, QList<QSslError>)));
|
||||||
}
|
}
|
||||||
|
|
||||||
DownloadDialog::~DownloadDialog()
|
DownloadDialog::~DownloadDialog() {
|
||||||
{
|
|
||||||
delete ui;
|
delete ui;
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownloadDialog::beginDownload (const QUrl &url)
|
void DownloadDialog::beginDownload (const QUrl &url) {
|
||||||
{
|
|
||||||
Q_ASSERT (!url.isEmpty());
|
Q_ASSERT (!url.isEmpty());
|
||||||
|
|
||||||
// Reset the UI
|
// Reset the UI
|
||||||
@ -57,10 +54,8 @@ void DownloadDialog::beginDownload (const QUrl &url)
|
|||||||
showNormal();
|
showNormal();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownloadDialog::openDownload()
|
void DownloadDialog::openDownload() {
|
||||||
{
|
if (!m_path.isEmpty()) {
|
||||||
if (!m_path.isEmpty())
|
|
||||||
{
|
|
||||||
QString url = m_path;
|
QString url = m_path;
|
||||||
|
|
||||||
if (url.startsWith ("/"))
|
if (url.startsWith ("/"))
|
||||||
@ -76,18 +71,15 @@ void DownloadDialog::openDownload()
|
|||||||
qWarning() << "QSimpleUpdater: cannot open downloaded file!";
|
qWarning() << "QSimpleUpdater: cannot open downloaded file!";
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownloadDialog::cancelDownload()
|
void DownloadDialog::cancelDownload() {
|
||||||
{
|
if (!m_reply->isFinished()) {
|
||||||
if (!m_reply->isFinished())
|
|
||||||
{
|
|
||||||
QMessageBox _message;
|
QMessageBox _message;
|
||||||
_message.setWindowTitle (tr ("Updater"));
|
_message.setWindowTitle (tr ("Updater"));
|
||||||
_message.setIcon (QMessageBox::Question);
|
_message.setIcon (QMessageBox::Question);
|
||||||
_message.setStandardButtons (QMessageBox::Yes | QMessageBox::No);
|
_message.setStandardButtons (QMessageBox::Yes | QMessageBox::No);
|
||||||
_message.setText (tr ("Are you sure you want to cancel the download?"));
|
_message.setText (tr ("Are you sure you want to cancel the download?"));
|
||||||
|
|
||||||
if (_message.exec() == QMessageBox::Yes)
|
if (_message.exec() == QMessageBox::Yes) {
|
||||||
{
|
|
||||||
hide();
|
hide();
|
||||||
m_reply->abort();
|
m_reply->abort();
|
||||||
}
|
}
|
||||||
@ -97,21 +89,18 @@ void DownloadDialog::cancelDownload()
|
|||||||
hide();
|
hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownloadDialog::downloadFinished()
|
void DownloadDialog::downloadFinished() {
|
||||||
{
|
|
||||||
ui->stopButton->setText (tr ("Close"));
|
ui->stopButton->setText (tr ("Close"));
|
||||||
ui->downloadLabel->setText (tr ("Download complete!"));
|
ui->downloadLabel->setText (tr ("Download complete!"));
|
||||||
ui->timeLabel->setText (tr ("The installer will open in a separate window..."));
|
ui->timeLabel->setText (tr ("The installer will open in a separate window..."));
|
||||||
|
|
||||||
QByteArray data = m_reply->readAll();
|
QByteArray data = m_reply->readAll();
|
||||||
|
|
||||||
if (!data.isEmpty())
|
if (!data.isEmpty()) {
|
||||||
{
|
|
||||||
QStringList list = m_reply->url().toString().split ("/");
|
QStringList list = m_reply->url().toString().split ("/");
|
||||||
QFile file (QDir::tempPath() + "/" + list.at (list.count() - 1));
|
QFile file (QDir::tempPath() + "/" + list.at (list.count() - 1));
|
||||||
|
|
||||||
if (file.open (QIODevice::WriteOnly))
|
if (file.open (QIODevice::WriteOnly)) {
|
||||||
{
|
|
||||||
file.write (data);
|
file.write (data);
|
||||||
m_path = file.fileName();
|
m_path = file.fileName();
|
||||||
}
|
}
|
||||||
@ -127,11 +116,9 @@ void DownloadDialog::downloadFinished()
|
|||||||
qWarning() << "QSimpleUpdater: invalid download data!";
|
qWarning() << "QSimpleUpdater: invalid download data!";
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownloadDialog::updateProgress (qint64 received, qint64 total)
|
void DownloadDialog::updateProgress (qint64 received, qint64 total) {
|
||||||
{
|
|
||||||
// We know the size of the download, so we can calculate the progress....
|
// We know the size of the download, so we can calculate the progress....
|
||||||
if (total > 0 && received > 0)
|
if (total > 0 && received > 0) {
|
||||||
{
|
|
||||||
ui->progressBar->setMinimum (0);
|
ui->progressBar->setMinimum (0);
|
||||||
ui->progressBar->setMaximum (100);
|
ui->progressBar->setMaximum (100);
|
||||||
|
|
||||||
@ -147,14 +134,12 @@ void DownloadDialog::updateProgress (qint64 received, qint64 total)
|
|||||||
if (_total < 1024)
|
if (_total < 1024)
|
||||||
_total_string = tr ("%1 bytes").arg (_total);
|
_total_string = tr ("%1 bytes").arg (_total);
|
||||||
|
|
||||||
else if (_total < 1024 * 1024)
|
else if (_total < 1024 * 1024) {
|
||||||
{
|
|
||||||
_total = roundNumber (_total / 1024);
|
_total = roundNumber (_total / 1024);
|
||||||
_total_string = tr ("%1 KB").arg (_total);
|
_total_string = tr ("%1 KB").arg (_total);
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
_total = roundNumber (_total / (1024 * 1024));
|
_total = roundNumber (_total / (1024 * 1024));
|
||||||
_total_string = tr ("%1 MB").arg (_total);
|
_total_string = tr ("%1 MB").arg (_total);
|
||||||
}
|
}
|
||||||
@ -162,14 +147,12 @@ void DownloadDialog::updateProgress (qint64 received, qint64 total)
|
|||||||
if (_received < 1024)
|
if (_received < 1024)
|
||||||
_received_string = tr ("%1 bytes").arg (_received);
|
_received_string = tr ("%1 bytes").arg (_received);
|
||||||
|
|
||||||
else if (received < 1024 * 1024)
|
else if (received < 1024 * 1024) {
|
||||||
{
|
|
||||||
_received = roundNumber (_received / 1024);
|
_received = roundNumber (_received / 1024);
|
||||||
_received_string = tr ("%1 KB").arg (_received);
|
_received_string = tr ("%1 KB").arg (_received);
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
_received = roundNumber (_received / (1024 * 1024));
|
_received = roundNumber (_received / (1024 * 1024));
|
||||||
_received_string = tr ("%1 MB").arg (_received);
|
_received_string = tr ("%1 MB").arg (_received);
|
||||||
}
|
}
|
||||||
@ -180,19 +163,16 @@ void DownloadDialog::updateProgress (qint64 received, qint64 total)
|
|||||||
|
|
||||||
uint _diff = QDateTime::currentDateTime().toTime_t() - m_start_time;
|
uint _diff = QDateTime::currentDateTime().toTime_t() - m_start_time;
|
||||||
|
|
||||||
if (_diff > 0)
|
if (_diff > 0) {
|
||||||
{
|
|
||||||
QString _time_string;
|
QString _time_string;
|
||||||
float _time_remaining = total / (received / _diff);
|
float _time_remaining = total / (received / _diff);
|
||||||
|
|
||||||
if (_time_remaining > 7200)
|
if (_time_remaining > 7200) {
|
||||||
{
|
|
||||||
_time_remaining /= 3600;
|
_time_remaining /= 3600;
|
||||||
_time_string = tr ("About %1 hours").arg (int (_time_remaining + 0.5));
|
_time_string = tr ("About %1 hours").arg (int (_time_remaining + 0.5));
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (_time_remaining > 60)
|
else if (_time_remaining > 60) {
|
||||||
{
|
|
||||||
_time_remaining /= 60;
|
_time_remaining /= 60;
|
||||||
_time_string = tr ("About %1 minutes").arg (int (_time_remaining + 0.5));
|
_time_string = tr ("About %1 minutes").arg (int (_time_remaining + 0.5));
|
||||||
}
|
}
|
||||||
@ -205,8 +185,7 @@ void DownloadDialog::updateProgress (qint64 received, qint64 total)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// We do not know the size of the download, so we improvise...
|
// We do not know the size of the download, so we improvise...
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
ui->progressBar->setValue (-1);
|
ui->progressBar->setValue (-1);
|
||||||
ui->progressBar->setMinimum (0);
|
ui->progressBar->setMinimum (0);
|
||||||
ui->progressBar->setMaximum (0);
|
ui->progressBar->setMaximum (0);
|
||||||
@ -215,12 +194,10 @@ void DownloadDialog::updateProgress (qint64 received, qint64 total)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void DownloadDialog::ignoreSslErrors (QNetworkReply *reply, const QList<QSslError> &error)
|
void DownloadDialog::ignoreSslErrors (QNetworkReply *reply, const QList<QSslError> &error) {
|
||||||
{
|
|
||||||
reply->ignoreSslErrors (error);
|
reply->ignoreSslErrors (error);
|
||||||
}
|
}
|
||||||
|
|
||||||
float DownloadDialog::roundNumber (const float &input)
|
float DownloadDialog::roundNumber (const float &input) {
|
||||||
{
|
|
||||||
return roundf (input * 100) / 100;
|
return roundf (input * 100) / 100;
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,7 @@ class DownloadDialog : public QWidget
|
|||||||
Ui::DownloadDialog *ui;
|
Ui::DownloadDialog *ui;
|
||||||
|
|
||||||
QString m_path;
|
QString m_path;
|
||||||
|
bool m_download_paused;
|
||||||
|
|
||||||
QNetworkReply *m_reply;
|
QNetworkReply *m_reply;
|
||||||
QNetworkAccessManager *m_manager;
|
QNetworkAccessManager *m_manager;
|
||||||
|
@ -108,6 +108,19 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer_2">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QProgressBar" name="progressBar">
|
<widget class="QProgressBar" name="progressBar">
|
||||||
<property name="value">
|
<property name="value">
|
||||||
@ -118,6 +131,19 @@
|
|||||||
</property>
|
</property>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item>
|
||||||
|
<spacer name="verticalSpacer">
|
||||||
|
<property name="orientation">
|
||||||
|
<enum>Qt::Vertical</enum>
|
||||||
|
</property>
|
||||||
|
<property name="sizeHint" stdset="0">
|
||||||
|
<size>
|
||||||
|
<width>20</width>
|
||||||
|
<height>40</height>
|
||||||
|
</size>
|
||||||
|
</property>
|
||||||
|
</spacer>
|
||||||
|
</item>
|
||||||
<item>
|
<item>
|
||||||
<widget class="QLabel" name="timeLabel">
|
<widget class="QLabel" name="timeLabel">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
|
@ -12,15 +12,12 @@ QSimpleUpdater::QSimpleUpdater (QObject *parent)
|
|||||||
: QObject (parent)
|
: QObject (parent)
|
||||||
, m_changelog_downloaded (false)
|
, m_changelog_downloaded (false)
|
||||||
, m_version_check_finished (false)
|
, m_version_check_finished (false)
|
||||||
, m_new_version_available (false)
|
, m_new_version_available (false) {
|
||||||
{
|
|
||||||
m_downloadDialog = new DownloadDialog();
|
m_downloadDialog = new DownloadDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QSimpleUpdater::changeLog() const
|
QString QSimpleUpdater::changeLog() const {
|
||||||
{
|
if (m_changelog.isEmpty()) {
|
||||||
if (m_changelog.isEmpty())
|
|
||||||
{
|
|
||||||
qDebug() << "QSimpleUpdater: change log is empty,"
|
qDebug() << "QSimpleUpdater: change log is empty,"
|
||||||
<< "did you call setChangelogUrl() and checkForUpdates()?";
|
<< "did you call setChangelogUrl() and checkForUpdates()?";
|
||||||
}
|
}
|
||||||
@ -28,10 +25,8 @@ QString QSimpleUpdater::changeLog() const
|
|||||||
return m_changelog;
|
return m_changelog;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QSimpleUpdater::checkForUpdates()
|
void QSimpleUpdater::checkForUpdates() {
|
||||||
{
|
if (!m_reference_url.isEmpty()) {
|
||||||
if (!m_reference_url.isEmpty())
|
|
||||||
{
|
|
||||||
QNetworkAccessManager *_manager = new QNetworkAccessManager (this);
|
QNetworkAccessManager *_manager = new QNetworkAccessManager (this);
|
||||||
|
|
||||||
connect (_manager, SIGNAL (finished (QNetworkReply *)),
|
connect (_manager, SIGNAL (finished (QNetworkReply *)),
|
||||||
@ -47,22 +42,18 @@ void QSimpleUpdater::checkForUpdates()
|
|||||||
qDebug() << "QSimpleUpdater: Invalid reference URL";
|
qDebug() << "QSimpleUpdater: Invalid reference URL";
|
||||||
}
|
}
|
||||||
|
|
||||||
void QSimpleUpdater::openDownloadLink()
|
void QSimpleUpdater::openDownloadLink() {
|
||||||
{
|
|
||||||
if (!m_download_url.isEmpty())
|
if (!m_download_url.isEmpty())
|
||||||
QDesktopServices::openUrl (m_download_url);
|
QDesktopServices::openUrl (m_download_url);
|
||||||
|
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
qDebug() << "QSimpleUpdater: cannot download latest version,"
|
qDebug() << "QSimpleUpdater: cannot download latest version,"
|
||||||
<< "did you call setDownloadUrl() and checkForUpdates()?";
|
<< "did you call setDownloadUrl() and checkForUpdates()?";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QSimpleUpdater::latestVersion() const
|
QString QSimpleUpdater::latestVersion() const {
|
||||||
{
|
if (m_latest_version.isEmpty()) {
|
||||||
if (m_latest_version.isEmpty())
|
|
||||||
{
|
|
||||||
qDebug() << "QSimpleUpdater: latest version is empty,"
|
qDebug() << "QSimpleUpdater: latest version is empty,"
|
||||||
<< "did you call checkForUpdates() and setReferenceUrl()?";
|
<< "did you call checkForUpdates() and setReferenceUrl()?";
|
||||||
}
|
}
|
||||||
@ -70,10 +61,8 @@ QString QSimpleUpdater::latestVersion() const
|
|||||||
return m_latest_version;
|
return m_latest_version;
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QSimpleUpdater::installedVersion() const
|
QString QSimpleUpdater::installedVersion() const {
|
||||||
{
|
if (m_installed_version.isEmpty()) {
|
||||||
if (m_installed_version.isEmpty())
|
|
||||||
{
|
|
||||||
qDebug() << "QSimpleUpdater: installed version is empty,"
|
qDebug() << "QSimpleUpdater: installed version is empty,"
|
||||||
<< "did you call setApplicationVersion()?";
|
<< "did you call setApplicationVersion()?";
|
||||||
}
|
}
|
||||||
@ -81,25 +70,21 @@ QString QSimpleUpdater::installedVersion() const
|
|||||||
return m_installed_version;
|
return m_installed_version;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QSimpleUpdater::downloadLatestVersion()
|
void QSimpleUpdater::downloadLatestVersion() {
|
||||||
{
|
|
||||||
if (!m_download_url.isEmpty())
|
if (!m_download_url.isEmpty())
|
||||||
m_downloadDialog->beginDownload (m_download_url);
|
m_downloadDialog->beginDownload (m_download_url);
|
||||||
|
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
qDebug() << "QSimpleUpdater: cannot download latest version,"
|
qDebug() << "QSimpleUpdater: cannot download latest version,"
|
||||||
<< "did you call setDownloadUrl() and checkForUpdates()?";
|
<< "did you call setDownloadUrl() and checkForUpdates()?";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QSimpleUpdater::newerVersionAvailable() const
|
bool QSimpleUpdater::newerVersionAvailable() const {
|
||||||
{
|
|
||||||
return m_new_version_available;
|
return m_new_version_available;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QSimpleUpdater::setDownloadUrl (const QString &url)
|
void QSimpleUpdater::setDownloadUrl (const QString &url) {
|
||||||
{
|
|
||||||
Q_ASSERT (!url.isEmpty());
|
Q_ASSERT (!url.isEmpty());
|
||||||
|
|
||||||
if (!url.isEmpty())
|
if (!url.isEmpty())
|
||||||
@ -109,8 +94,7 @@ void QSimpleUpdater::setDownloadUrl (const QString &url)
|
|||||||
qDebug() << "QSimpleUpdater: input URL cannot be empty!";
|
qDebug() << "QSimpleUpdater: input URL cannot be empty!";
|
||||||
}
|
}
|
||||||
|
|
||||||
void QSimpleUpdater::setReferenceUrl (const QString &url)
|
void QSimpleUpdater::setReferenceUrl (const QString &url) {
|
||||||
{
|
|
||||||
Q_ASSERT (!url.isEmpty());
|
Q_ASSERT (!url.isEmpty());
|
||||||
|
|
||||||
if (!url.isEmpty())
|
if (!url.isEmpty())
|
||||||
@ -120,8 +104,7 @@ void QSimpleUpdater::setReferenceUrl (const QString &url)
|
|||||||
qDebug() << "QSimpleUpdater: input URL cannot be empty!";
|
qDebug() << "QSimpleUpdater: input URL cannot be empty!";
|
||||||
}
|
}
|
||||||
|
|
||||||
void QSimpleUpdater::setChangelogUrl (const QString &url)
|
void QSimpleUpdater::setChangelogUrl (const QString &url) {
|
||||||
{
|
|
||||||
Q_ASSERT (!url.isEmpty());
|
Q_ASSERT (!url.isEmpty());
|
||||||
|
|
||||||
if (!url.isEmpty())
|
if (!url.isEmpty())
|
||||||
@ -131,8 +114,7 @@ void QSimpleUpdater::setChangelogUrl (const QString &url)
|
|||||||
qDebug() << "QSimpleUpdater: input URL cannot be empty!";
|
qDebug() << "QSimpleUpdater: input URL cannot be empty!";
|
||||||
}
|
}
|
||||||
|
|
||||||
void QSimpleUpdater::setApplicationVersion (const QString &version)
|
void QSimpleUpdater::setApplicationVersion (const QString &version) {
|
||||||
{
|
|
||||||
Q_ASSERT (!version.isEmpty());
|
Q_ASSERT (!version.isEmpty());
|
||||||
|
|
||||||
if (!version.isEmpty())
|
if (!version.isEmpty())
|
||||||
@ -142,41 +124,33 @@ void QSimpleUpdater::setApplicationVersion (const QString &version)
|
|||||||
qDebug() << "QSimpleUpdater: input string cannot be empty!";
|
qDebug() << "QSimpleUpdater: input string cannot be empty!";
|
||||||
}
|
}
|
||||||
|
|
||||||
void QSimpleUpdater::checkDownloadedVersion (QNetworkReply *reply)
|
void QSimpleUpdater::checkDownloadedVersion (QNetworkReply *reply) {
|
||||||
{
|
|
||||||
bool _new_update = false;
|
bool _new_update = false;
|
||||||
|
|
||||||
QString _reply = QString::fromUtf8 (reply->readAll());
|
QString _reply = QString::fromUtf8 (reply->readAll());
|
||||||
_reply.replace (" ", "");
|
_reply.replace (" ", "");
|
||||||
_reply.replace ("\n", "");
|
_reply.replace ("\n", "");
|
||||||
|
|
||||||
if (!_reply.isEmpty() && _reply.contains ("."))
|
if (!_reply.isEmpty() && _reply.contains (".")) {
|
||||||
{
|
|
||||||
m_latest_version = _reply;
|
m_latest_version = _reply;
|
||||||
|
|
||||||
QStringList _download = m_latest_version.split (".");
|
QStringList _download = m_latest_version.split (".");
|
||||||
QStringList _installed = m_installed_version.split (".");
|
QStringList _installed = m_installed_version.split (".");
|
||||||
|
|
||||||
for (int i = 0; i <= _download.count() - 1; ++i)
|
for (int i = 0; i <= _download.count() - 1; ++i) {
|
||||||
{
|
if (_download.count() - 1 >= i && _installed.count() - 1 >= i) {
|
||||||
if (_download.count() - 1 >= i && _installed.count() - 1 >= i)
|
if (_download.at (i) > _installed.at (i)) {
|
||||||
{
|
|
||||||
if (_download.at (i) > _installed.at (i))
|
|
||||||
{
|
|
||||||
_new_update = true;
|
_new_update = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else {
|
||||||
{
|
if (_installed.count() < _download.count()) {
|
||||||
if (_installed.count() < _download.count())
|
|
||||||
{
|
|
||||||
if (_installed.at (i - 1) == _download.at (i - 1))
|
if (_installed.at (i - 1) == _download.at (i - 1))
|
||||||
break;
|
break;
|
||||||
|
|
||||||
else
|
else {
|
||||||
{
|
|
||||||
_new_update = true;
|
_new_update = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -188,8 +162,7 @@ void QSimpleUpdater::checkDownloadedVersion (QNetworkReply *reply)
|
|||||||
m_new_version_available = _new_update;
|
m_new_version_available = _new_update;
|
||||||
emit versionCheckFinished();
|
emit versionCheckFinished();
|
||||||
|
|
||||||
if (!m_changelog_url.isEmpty() && newerVersionAvailable())
|
if (!m_changelog_url.isEmpty() && newerVersionAvailable()) {
|
||||||
{
|
|
||||||
QNetworkAccessManager *_manager = new QNetworkAccessManager (this);
|
QNetworkAccessManager *_manager = new QNetworkAccessManager (this);
|
||||||
|
|
||||||
connect (_manager, SIGNAL (finished (QNetworkReply *)),
|
connect (_manager, SIGNAL (finished (QNetworkReply *)),
|
||||||
@ -205,23 +178,20 @@ void QSimpleUpdater::checkDownloadedVersion (QNetworkReply *reply)
|
|||||||
emit checkingFinished();
|
emit checkingFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QSimpleUpdater::processDownloadedChangelog (QNetworkReply *reply)
|
void QSimpleUpdater::processDownloadedChangelog (QNetworkReply *reply) {
|
||||||
{
|
|
||||||
QString _reply = QString::fromUtf8 (reply->readAll());
|
QString _reply = QString::fromUtf8 (reply->readAll());
|
||||||
|
|
||||||
if (!_reply.isEmpty())
|
if (!_reply.isEmpty()) {
|
||||||
{
|
|
||||||
m_changelog = _reply;
|
m_changelog = _reply;
|
||||||
emit changelogDownloadFinished();
|
emit changelogDownloadFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
qDebug() << "QSimpleUpdater: downloaded change log is empty!";
|
qDebug() << "QSimpleUpdater: downloaded change log is empty!";
|
||||||
|
|
||||||
emit checkingFinished();
|
emit checkingFinished();
|
||||||
}
|
}
|
||||||
|
|
||||||
void QSimpleUpdater::ignoreSslErrors (QNetworkReply *reply, const QList<QSslError> &error)
|
void QSimpleUpdater::ignoreSslErrors (QNetworkReply *reply, const QList<QSslError> &error) {
|
||||||
{
|
|
||||||
reply->ignoreSslErrors (error);
|
reply->ignoreSslErrors (error);
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user