Skip to content

Commit

Permalink
detect capabilities for lock/unlock of files
Browse files Browse the repository at this point in the history
Signed-off-by: Matthieu Gallien <[email protected]>
  • Loading branch information
mgallien committed Apr 29, 2022
1 parent 2da5883 commit 7c48b31
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/libsync/capabilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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")) {
Expand Down
1 change: 1 addition & 0 deletions src/libsync/capabilities.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
14 changes: 14 additions & 0 deletions test/testcapabilities.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 7c48b31

Please sign in to comment.