27#include <QNetworkRequest>
28#include <QNetworkReply>
38 QStringList v = s.split(QLatin1Char(
'.'));
83 return !operator<(other);
103 if (*
this == other) {
106 return *
this < other;
111 return QSL(
"%1.%2.%3").arg(majorVersion, minorVersion, revisionNumber);
118 QTimer::singleShot(60 * 1000,
this, &Updater::start);
123 QUrl url = QUrl(
QSL(
"%1/update.php?v=%2&os=%3").arg(QString::fromLatin1(
Qz::WWWADDRESS),
127 startDownloadingUpdateInfo(url);
130void Updater::startDownloadingUpdateInfo(
const QUrl &url)
132 QNetworkReply *reply =
mApp->networkManager()->get(QNetworkRequest(QUrl(url)));
134 connect(reply, &QNetworkReply::finished,
this, &Updater::downCompleted);
137void Updater::downCompleted()
139 auto* reply = qobject_cast<QNetworkReply*>(sender());
143 QString html = QString::fromUtf8(reply->readAll());
145 if (html.startsWith(QLatin1String(
"Version:"))) {
146 html.remove(QLatin1String(
"Version:"));
148 Version updated(html);
150 if (current.isValid && updated.isValid && current < updated) {
151 mApp->desktopNotifications()->showNotification(QIcon(
QSL(
":icons/falkon.svg")).pixmap(48), tr(
"Update available"), tr(
"New version of Falkon is ready to download."));
155 reply->deleteLater();
158void Updater::downloadNewVersion()
162 QByteArray(QByteArray(
Qz::WWWADDRESS) + QByteArray(
"/download"))),
TabWidget * tabWidget() const
Updater(BrowserWindow *window, QObject *parent=nullptr)
FALKON_EXPORT const char * VERSION
FALKON_EXPORT const char * WWWADDRESS
bool operator<=(const Version &other) const
bool operator>(const Version &other) const
bool operator==(const Version &other) const
QString versionString() const
bool operator>=(const Version &other) const
Version(const QString &s)
bool operator<(const Version &other) const