From ef867e5abbfb19afe95f5062c3f690fa1c7a8713 Mon Sep 17 00:00:00 2001 From: Matthieu Gallien Date: Thu, 7 Apr 2022 10:44:54 +0200 Subject: [PATCH] detect capabilities for lock/unlock of files Signed-off-by: Matthieu Gallien --- src/libsync/capabilities.cpp | 5 +++++ src/libsync/capabilities.h | 1 + test/testcapabilities.cpp | 14 ++++++++++++++ 3 files changed, 20 insertions(+) diff --git a/src/libsync/capabilities.cpp b/src/libsync/capabilities.cpp index 155048a76ea69..da713b46cfe48 100644 --- a/src/libsync/capabilities.cpp +++ b/src/libsync/capabilities.cpp @@ -221,6 +221,11 @@ bool Capabilities::bulkUpload() const return _capabilities["dav"].toMap()["bulkupload"].toByteArray() >= "1.0"; } +bool Capabilities::filesLockAvailable() const +{ + return _capabilities["files"].toMap()["locking"].toByteArray() >= "1.0"; +} + bool Capabilities::userStatus() const { if (!_capabilities.contains("user_status")) { diff --git a/src/libsync/capabilities.h b/src/libsync/capabilities.h index 6bbb3e0220803..bbc2fd1b60a85 100644 --- a/src/libsync/capabilities.h +++ b/src/libsync/capabilities.h @@ -65,6 +65,7 @@ class OWNCLOUDSYNC_EXPORT Capabilities int shareDefaultPermissions() const; bool chunkingNg() const; bool bulkUpload() const; + bool filesLockAvailable() const; bool userStatus() const; bool userStatusSupportsEmoji() const; QColor serverColor() const; diff --git a/test/testcapabilities.cpp b/test/testcapabilities.cpp index 2088cc7b0b02b..1952d7f3661e5 100644 --- a/test/testcapabilities.cpp +++ b/test/testcapabilities.cpp @@ -257,6 +257,20 @@ private slots: QCOMPARE(bulkuploadAvailable, true); } + + void testFilesLockAvailable_filesLockAvailable_returnTrue() + { + QVariantMap filesMap; + filesMap["locking"] = "1.0"; + + QVariantMap capabilitiesMap; + capabilitiesMap["files"] = filesMap; + + const auto &capabilities = OCC::Capabilities(capabilitiesMap); + const auto filesLockAvailable = capabilities.filesLockAvailable(); + + QCOMPARE(filesLockAvailable, true); + } }; QTEST_GUILESS_MAIN(TestCapabilities)