|
|
@ -36,7 +36,6 @@ |
|
|
|
#include <QDebug> |
|
|
|
#include <QDebug> |
|
|
|
#include <QDesktopServices> |
|
|
|
#include <QDesktopServices> |
|
|
|
#include <QRegularExpression> |
|
|
|
#include <QRegularExpression> |
|
|
|
#include <QStringList> |
|
|
|
|
|
|
|
#include <QXmlStreamReader> |
|
|
|
#include <QXmlStreamReader> |
|
|
|
|
|
|
|
|
|
|
|
#if defined(Q_OS_WIN) |
|
|
|
#if defined(Q_OS_WIN) |
|
|
@ -44,35 +43,32 @@ |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
|
|
#include "base/net/downloadmanager.h" |
|
|
|
#include "base/net/downloadmanager.h" |
|
|
|
|
|
|
|
#include "base/utils/version.h" |
|
|
|
#include "base/version.h" |
|
|
|
#include "base/version.h" |
|
|
|
|
|
|
|
|
|
|
|
namespace |
|
|
|
namespace |
|
|
|
{ |
|
|
|
{ |
|
|
|
bool isVersionMoreRecent(const QString &remoteVersion) |
|
|
|
bool isVersionMoreRecent(const QString &remoteVersion) |
|
|
|
{ |
|
|
|
{ |
|
|
|
const QRegularExpressionMatch regVerMatch = QRegularExpression("([0-9.]+)").match(QBT_VERSION); |
|
|
|
using Version = Utils::Version<int, 4, 3>; |
|
|
|
if (regVerMatch.hasMatch()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
const QString localVersion = regVerMatch.captured(1); |
|
|
|
|
|
|
|
const QVector<QStringRef> remoteParts = remoteVersion.splitRef('.'); |
|
|
|
|
|
|
|
const QVector<QStringRef> localParts = localVersion.splitRef('.'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < qMin(remoteParts.size(), localParts.size()); ++i) |
|
|
|
try |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
const Version newVersion {remoteVersion}; |
|
|
|
|
|
|
|
const Version currentVersion {QBT_VERSION_MAJOR, QBT_VERSION_MINOR, QBT_VERSION_BUGFIX, QBT_VERSION_BUILD}; |
|
|
|
|
|
|
|
if (newVersion == currentVersion) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (remoteParts[i].toInt() > localParts[i].toInt()) |
|
|
|
const bool isDevVersion = QString::fromLatin1(QBT_VERSION_STATUS).contains( |
|
|
|
|
|
|
|
QRegularExpression(QLatin1String("(alpha|beta|rc)"))); |
|
|
|
|
|
|
|
if (isDevVersion) |
|
|
|
return true; |
|
|
|
return true; |
|
|
|
if (remoteParts[i].toInt() < localParts[i].toInt()) |
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
// Compared parts were equal, if remote version is longer, then it's more recent (2.9.2.1 > 2.9.2)
|
|
|
|
return (newVersion > currentVersion); |
|
|
|
if (remoteParts.size() > localParts.size()) |
|
|
|
} |
|
|
|
return true; |
|
|
|
catch (const std::runtime_error &) |
|
|
|
// versions are equal, check if the local version is a development release, in which case it is older (2.9.2beta < 2.9.2)
|
|
|
|
{ |
|
|
|
const QRegularExpressionMatch regDevelMatch = QRegularExpression("(alpha|beta|rc)").match(QBT_VERSION); |
|
|
|
return false; |
|
|
|
if (regDevelMatch.hasMatch()) |
|
|
|
|
|
|
|
return true; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
return false; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|