mirror of
https://invent.kde.org/network/falkon.git
synced 2024-12-20 10:46:35 +01:00
[Updater] Fixed comparison of version numbers.
Also dropped support for rc/beta versions.
This commit is contained in:
parent
3e546ebb70
commit
eeb1231c75
@ -67,16 +67,6 @@ void ProfileUpdater::updateProfile(const QString ¤t, const QString &profil
|
||||
// Updater::Version currentVersion = Updater::parseVersionFromString(current);
|
||||
Updater::Version profileVersion = Updater::parseVersionFromString(profile);
|
||||
|
||||
if (profileVersion == Updater::parseVersionFromString("1.0.0-b4")) {
|
||||
update100b4();
|
||||
return;
|
||||
}
|
||||
|
||||
if (profileVersion == Updater::parseVersionFromString("1.0.0-rc1")) {
|
||||
update100rc1();
|
||||
return;
|
||||
}
|
||||
|
||||
if (profileVersion == Updater::parseVersionFromString("1.0.0")) {
|
||||
update100();
|
||||
return;
|
||||
@ -131,33 +121,6 @@ void ProfileUpdater::copyDataToProfile()
|
||||
QFile(m_profilePath + "browsedata.db").setPermissions(QFile::ReadUser | QFile::WriteUser);
|
||||
}
|
||||
|
||||
void ProfileUpdater::update100b4()
|
||||
{
|
||||
std::cout << "QupZilla: Upgrading profile version from 1.0.0-b4..." << std::endl;
|
||||
mApp->connectDatabase();
|
||||
|
||||
QSqlQuery query;
|
||||
query.exec("CREATE TABLE IF NOT EXISTS search_engines (id INTEGER PRIMARY KEY, name TEXT, icon TEXT,"
|
||||
"url TEXT, shortcut TEXT, suggestionsUrl TEXT, suggestionsParameters TEXT);");
|
||||
|
||||
update100rc1();
|
||||
}
|
||||
|
||||
void ProfileUpdater::update100rc1()
|
||||
{
|
||||
std::cout << "QupZilla: Upgrading profile version from 1.0.0-rc1..." << std::endl;
|
||||
mApp->connectDatabase();
|
||||
|
||||
QSqlQuery query;
|
||||
query.exec("ALTER TABLE folders ADD COLUMN subfolder TEXT");
|
||||
query.exec("UPDATE folders SET subfolder='no'");
|
||||
|
||||
query.exec("ALTER TABLE bookmarks ADD COLUMN toolbar_position NUMERIC");
|
||||
query.exec("UPDATE bookmarks SET toolbar_position=0");
|
||||
|
||||
update100();
|
||||
}
|
||||
|
||||
void ProfileUpdater::update100()
|
||||
{
|
||||
std::cout << "QupZilla: Upgrading profile version from 1.0.0..." << std::endl;
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* ============================================================
|
||||
* QupZilla - WebKit based browser
|
||||
* Copyright (C) 2010-2012 David Rosca <nowrep@gmail.com>
|
||||
* Copyright (C) 2010-2013 David Rosca <nowrep@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -32,8 +32,6 @@ private:
|
||||
void updateProfile(const QString ¤t, const QString &profile);
|
||||
void copyDataToProfile();
|
||||
|
||||
void update100b4();
|
||||
void update100rc1();
|
||||
void update100();
|
||||
void update118();
|
||||
void update120();
|
||||
|
@ -44,54 +44,27 @@ Updater::Version Updater::parseVersionFromString(const QString &string)
|
||||
return ver;
|
||||
}
|
||||
|
||||
QStringList r = v.at(2).split(QLatin1Char('.'));
|
||||
bool ok;
|
||||
|
||||
ver.majorVersion = v.at(0).toInt();
|
||||
ver.minorVersion = v.at(1).toInt();
|
||||
ver.revisionNumber = r.at(0).toInt();
|
||||
if (r.count() == 2) {
|
||||
ver.specialSymbol = r.at(1);
|
||||
ver.majorVersion = v.at(0).toInt(&ok);
|
||||
if (!ok) {
|
||||
return ver;
|
||||
}
|
||||
|
||||
ver.minorVersion = v.at(1).toInt(&ok);
|
||||
if (!ok) {
|
||||
return ver;
|
||||
}
|
||||
|
||||
ver.revisionNumber = v.at(2).toInt(&ok);
|
||||
if (!ok) {
|
||||
return ver;
|
||||
}
|
||||
|
||||
ver.isValid = true;
|
||||
return ver;
|
||||
}
|
||||
|
||||
bool Updater::isBiggerThan_SpecialSymbol(QString one, QString two)
|
||||
{
|
||||
if (one.contains(QLatin1String("rc")) && two.contains(QLatin1Char('b'))) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (one.contains(QLatin1Char('b')) && two.contains(QLatin1String("rc"))) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (one.isEmpty()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (two.isEmpty()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (one.contains(QLatin1Char('b'))) {
|
||||
int o = one.remove(QLatin1Char('b')).toInt();
|
||||
int t = two.remove(QLatin1Char('b')).toInt();
|
||||
|
||||
return o > t;
|
||||
}
|
||||
|
||||
if (one.contains(QLatin1String("rc"))) {
|
||||
int o = one.remove(QLatin1String("rc")).toInt();
|
||||
int t = two.remove(QLatin1String("rc")).toInt();
|
||||
|
||||
return o > t;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void Updater::start()
|
||||
{
|
||||
QUrl url = QUrl(QString("%1/update.php?v=%2&os=%3").arg(QupZilla::WWWADDRESS,
|
||||
@ -118,7 +91,7 @@ void Updater::downCompleted(QNetworkReply* reply)
|
||||
Version current = parseVersionFromString(QupZilla::VERSION);
|
||||
Version updated = parseVersionFromString(html);
|
||||
|
||||
if (current < updated) {
|
||||
if (current.isValid && updated.isValid && current < updated) {
|
||||
mApp->desktopNotifications()->showNotification(QPixmap(":icons/qupzillaupdate.png"), tr("Update available"), tr("New version of QupZilla is ready to download."));
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
/* ============================================================
|
||||
* QupZilla - WebKit based browser
|
||||
* Copyright (C) 2010-2012 David Rosca <nowrep@gmail.com>
|
||||
* Copyright (C) 2010-2013 David Rosca <nowrep@gmail.com>
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -39,19 +39,14 @@ public:
|
||||
int majorVersion;
|
||||
int minorVersion;
|
||||
int revisionNumber;
|
||||
QString specialSymbol;
|
||||
|
||||
bool operator<(const Version &other) const {
|
||||
if (!this->isValid || !other.isValid)
|
||||
return false;
|
||||
if (this->majorVersion < other.majorVersion)
|
||||
return true;
|
||||
if (this->minorVersion < other.minorVersion)
|
||||
return true;
|
||||
if (this->revisionNumber < other.revisionNumber)
|
||||
return true;
|
||||
if (this->revisionNumber == other.revisionNumber)
|
||||
return !isBiggerThan_SpecialSymbol(this->specialSymbol, other.specialSymbol);
|
||||
|
||||
return false;
|
||||
}
|
||||
@ -61,13 +56,9 @@ public:
|
||||
}
|
||||
|
||||
bool operator==(const Version &other) const {
|
||||
if (!this->isValid || !other.isValid)
|
||||
return false;
|
||||
|
||||
return (this->majorVersion == other.majorVersion &&
|
||||
this->minorVersion == other.minorVersion &&
|
||||
this->revisionNumber == other.revisionNumber &&
|
||||
this->specialSymbol == other.specialSymbol);
|
||||
this->revisionNumber == other.revisionNumber);
|
||||
}
|
||||
|
||||
bool operator>=(const Version &other) const {
|
||||
@ -84,9 +75,6 @@ public:
|
||||
};
|
||||
|
||||
static Version parseVersionFromString(const QString &string);
|
||||
static bool isBiggerThan_SpecialSymbol(QString one, QString two);
|
||||
|
||||
signals:
|
||||
|
||||
private slots:
|
||||
void downCompleted(QNetworkReply* reply);
|
||||
|
Loading…
Reference in New Issue
Block a user