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

github.com/nextcloud/desktop.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKevin Ottens <kevin.ottens@nextcloud.com>2020-07-15 16:26:45 +0300
committerKevin Ottens <ervin@ipsquad.net>2020-07-15 19:39:29 +0300
commitf46276d70d9017873b163ea5cee3fc04b6c9ad39 (patch)
tree80583cefca76acd37cbaf65850df4720a468df1d
parent15f9eeeb082bd2153954204eeed3a4b4d7c423b3 (diff)
Update our E2E API requirementv2.7.0-beta3
Now that we adjusted our protocol to follow the slightly updated server API, let's make sure we don't try to talk to a server with an older API. Signed-off-by: Kevin Ottens <kevin.ottens@nextcloud.com>
-rw-r--r--src/libsync/capabilities.cpp32
1 files changed, 29 insertions, 3 deletions
diff --git a/src/libsync/capabilities.cpp b/src/libsync/capabilities.cpp
index 190edfe77..78035fa8c 100644
--- a/src/libsync/capabilities.cpp
+++ b/src/libsync/capabilities.cpp
@@ -87,9 +87,35 @@ bool Capabilities::shareResharing() const
bool Capabilities::clientSideEncryptionAvailable() const
{
auto it = _capabilities.constFind(QStringLiteral("end-to-end-encryption"));
- if (it != _capabilities.constEnd())
- return (*it).toMap().value(QStringLiteral("enabled"), false).toBool();
- return false;
+ if (it == _capabilities.constEnd()) {
+ return false;
+ }
+
+ const auto properties = (*it).toMap();
+ const auto enabled = properties.value(QStringLiteral("enabled"), false).toBool();
+ if (!enabled) {
+ return false;
+ }
+
+ const auto version = properties.value(QStringLiteral("api-version"), "1.0").toByteArray();
+ qCInfo(lcServerCapabilities) << "E2EE API version:" << version;
+ const auto splittedVersion = version.split('.');
+
+ bool ok = false;
+ const auto major = !splittedVersion.isEmpty() ? splittedVersion.at(0).toInt(&ok) : 0;
+ if (!ok) {
+ qCWarning(lcServerCapabilities) << "Didn't understand version scheme (major), E2EE disabled";
+ return false;
+ }
+
+ ok = false;
+ const auto minor = splittedVersion.size() > 1 ? splittedVersion.at(1).toInt(&ok) : 0;
+ if (!ok) {
+ qCWarning(lcServerCapabilities) << "Didn't understand version scheme (minor), E2EE disabled";
+ return false;
+ }
+
+ return major == 1 && minor >= 1;
}
bool Capabilities::notificationsAvailable() const