Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/owncloud/client.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHannah von Reth <hannah.vonreth@owncloud.com>2021-11-02 16:12:24 +0300
committerHannah von Reth <vonreth@kde.org>2021-11-03 17:14:57 +0300
commit3ea52cc67d601922f5336194613b81eadd10a941 (patch)
treebec2e59e52d82c07d2b7178ab5bcd62b6be9154e /src/common
parent8b743376b1d230b76558703dfa70c289c64b464c (diff)
Use QVersionNumber for our own version
Diffstat (limited to 'src/common')
-rw-r--r--src/common/syncjournaldb.cpp18
-rw-r--r--src/common/utility.cpp2
-rw-r--r--src/common/version.cpp.in28
-rw-r--r--src/common/version.h36
-rw-r--r--src/common/vfs.cpp2
-rw-r--r--src/common/vfs.h3
-rw-r--r--src/common/vfspluginmetadata.json.in2
7 files changed, 40 insertions, 51 deletions
diff --git a/src/common/syncjournaldb.cpp b/src/common/syncjournaldb.cpp
index 5ace25c85..59b7ea1e4 100644
--- a/src/common/syncjournaldb.cpp
+++ b/src/common/syncjournaldb.cpp
@@ -516,10 +516,10 @@ bool SyncJournalDb::checkConnect()
forceRemoteDiscovery = true;
createQuery.prepare("INSERT INTO version VALUES (?1, ?2, ?3, ?4);");
- createQuery.bindValue(1, OCC::Version::major());
- createQuery.bindValue(2, OCC::Version::minor());
- createQuery.bindValue(3, OCC::Version::patch());
- createQuery.bindValue(4, OCC::Version::buildNumber());
+ const auto segments = OCC::Version::versionWithBuildNumber().segments();
+ for (int i = 0; i < segments.size(); ++i) {
+ createQuery.bindValue(i + 1, segments[i]);
+ }
if (!createQuery.exec()) {
return sqlFail(QStringLiteral("Update version"), createQuery);
}
@@ -544,13 +544,13 @@ bool SyncJournalDb::checkConnect()
}
// Not comparing the BUILD id here, correct?
- if (!(major == OCC::Version::major() && minor == OCC::Version::minor() && patch == OCC::Version::patch())) {
+ if (QVersionNumber(major, minor, patch) != OCC::Version::version()) {
createQuery.prepare("UPDATE version SET major=?1, minor=?2, patch =?3, custom=?4 "
"WHERE major=?5 AND minor=?6 AND patch=?7;");
- createQuery.bindValue(1, OCC::Version::major());
- createQuery.bindValue(2, OCC::Version::minor());
- createQuery.bindValue(3, OCC::Version::patch());
- createQuery.bindValue(4, OCC::Version::buildNumber());
+ const auto segments = OCC::Version::versionWithBuildNumber().segments();
+ for (int i = 0; i < segments.size(); ++i) {
+ createQuery.bindValue(i + 1, segments[i]);
+ }
createQuery.bindValue(5, major);
createQuery.bindValue(6, minor);
createQuery.bindValue(7, patch);
diff --git a/src/common/utility.cpp b/src/common/utility.cpp
index 5bde9099b..861424ac3 100644
--- a/src/common/utility.cpp
+++ b/src/common/utility.cpp
@@ -140,7 +140,7 @@ QByteArray Utility::userAgentString()
{
return QStringLiteral("Mozilla/5.0 (%1) mirall/%2 (%3, %4-%5 ClientArchitecture: %6 OsArchitecture: %7)")
.arg(platform(),
- OCC::Version::string(),
+ OCC::Version::displayString(),
// accessing the theme to fetch the string is rather difficult
// since this is only needed server-side to identify clients, the app name (as of 2.9, the short name) is good enough
qApp->applicationName(),
diff --git a/src/common/version.cpp.in b/src/common/version.cpp.in
index bab0081dc..8bfa00e45 100644
--- a/src/common/version.cpp.in
+++ b/src/common/version.cpp.in
@@ -18,29 +18,16 @@
#include "common/version.h"
-QString OCC::Version::string()
+const QVersionNumber &OCC::Version::version()
{
- return QStringLiteral("@MIRALL_VERSION_STRING@");
+ static const auto v = QVersionNumber({ @MIRALL_VERSION_MAJOR@, @MIRALL_VERSION_MINOR@, @MIRALL_VERSION_PATCH@ });
+ return v;
}
-int OCC::Version::major()
+const QVersionNumber &OCC::Version::versionWithBuildNumber()
{
- return @MIRALL_VERSION_MAJOR@;
-}
-
-int OCC::Version::minor()
-{
- return @MIRALL_VERSION_MINOR@;
-}
-
-int OCC::Version::patch()
-{
- return @MIRALL_VERSION_PATCH@;
-}
-
-int OCC::Version::buildNumber()
-{
- return @MIRALL_VERSION_BUILD@;
+ static const auto v = QVersionNumber({ @MIRALL_VERSION_MAJOR@, @MIRALL_VERSION_MINOR@, @MIRALL_VERSION_PATCH@, @MIRALL_VERSION_BUILD@ });
+ return v;
}
QString OCC::Version::gitSha()
@@ -52,6 +39,3 @@ QString OCC::Version::suffix()
{
return QStringLiteral("@MIRALL_VERSION_SUFFIX@");
}
-
-
-
diff --git a/src/common/version.h b/src/common/version.h
index 44a6cd698..2d93d3125 100644
--- a/src/common/version.h
+++ b/src/common/version.h
@@ -20,27 +20,31 @@
#include "ocsynclib.h"
#include <QString>
+#include <QVersionNumber>
-namespace OCC {
-namespace Version {
- /**
- * "Major.Minor.Patch"
- */
- QString OCSYNC_EXPORT string();
- int OCSYNC_EXPORT major();
- int OCSYNC_EXPORT minor();
- int OCSYNC_EXPORT patch();
- int OCSYNC_EXPORT buildNumber();
-
- /**
+namespace OCC::Version {
+OCSYNC_EXPORT const QVersionNumber &version();
+
+OCSYNC_EXPORT const QVersionNumber &versionWithBuildNumber();
+
+inline int buildNumber()
+{
+ return versionWithBuildNumber().segmentAt(3);
+}
+
+/**
* git, rc1, rc2
* Empty in releases
*/
- QString OCSYNC_EXPORT suffix();
- /**
+OCSYNC_EXPORT QString suffix();
+
+/**
* The commit id
*/
- QString OCSYNC_EXPORT gitSha();
-}
+OCSYNC_EXPORT QString gitSha();
+inline auto displayString()
+{
+ return QStringLiteral("%1-%2").arg(versionWithBuildNumber().toString(), suffix());
+}
}
diff --git a/src/common/vfs.cpp b/src/common/vfs.cpp
index 8627ca8ea..f3c67920f 100644
--- a/src/common/vfs.cpp
+++ b/src/common/vfs.cpp
@@ -182,7 +182,7 @@ bool OCC::isVfsPluginAvailable(Vfs::Mode mode)
qCWarning(lcPlugin) << "Plugin has wrong type" << loader.fileName() << metadata[QStringLiteral("type")];
return false;
}
- if (metadata[QStringLiteral("version")].toString() != OCC::Version::string()) {
+ if (metadata[QStringLiteral("version")].toString() != OCC::Version::version().toString()) {
qCWarning(lcPlugin) << "Plugin has wrong version" << loader.fileName() << metadata[QStringLiteral("version")];
return false;
}
diff --git a/src/common/vfs.h b/src/common/vfs.h
index 12680c329..7efde8ad7 100644
--- a/src/common/vfs.h
+++ b/src/common/vfs.h
@@ -16,6 +16,7 @@
#include <QObject>
#include <QScopedPointer>
#include <QSharedPointer>
+#include <QVersionNumber>
#include <memory>
@@ -62,7 +63,7 @@ struct OCSYNC_EXPORT VfsSetupParams
/// Strings potentially passed on to the platform
QString providerDisplayName;
QString providerName;
- QString providerVersion;
+ QVersionNumber providerVersion;
/** when registering with the system we might use
* a different presentaton to identify the accounts
diff --git a/src/common/vfspluginmetadata.json.in b/src/common/vfspluginmetadata.json.in
index 82c447ad5..b17d2a9f5 100644
--- a/src/common/vfspluginmetadata.json.in
+++ b/src/common/vfspluginmetadata.json.in
@@ -1,4 +1,4 @@
{
"type": "vfs",
- "version": "@MIRALL_VERSION_STRING@"
+ "version": "@MIRALL_VERSION@"
}