mirror of
https://github.com/nextcloud/desktop.git
synced 2025-10-26 11:17:43 +00:00
The rules to select the webdav url are now: - If the server reports that the new chunking algorithm is working, always use remote.php/dav/files/<username> This capability can be overriden with an environment variable - Otherwise, use the dav path provided by the theme, which defaults to remote.php/webdav This means that with the newer server, the branding can no longer override the webdav URL. If there is still an usecase for the branding to do so, we need to find another way to override it. But it is now more complicated to configure as might need include the username and need different endpoint depending on the operations (chunks or not) Issue #4007
121 lines
3.5 KiB
C++
121 lines
3.5 KiB
C++
/*
|
|
* Copyright (C) by Roeland Jago Douma <roeland@famdouma.nl>
|
|
*
|
|
* 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
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
* (at your option) any later version.
|
|
*
|
|
* This program is distributed in the hope that it will be useful, but
|
|
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
|
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
* for more details.
|
|
*/
|
|
|
|
#include "capabilities.h"
|
|
|
|
#include "configfile.h"
|
|
|
|
#include <QVariantMap>
|
|
#include <QDebug>
|
|
|
|
namespace OCC {
|
|
|
|
|
|
Capabilities::Capabilities(const QVariantMap &capabilities)
|
|
: _capabilities(capabilities)
|
|
{
|
|
}
|
|
|
|
bool Capabilities::shareAPI() const
|
|
{
|
|
if (_capabilities["files_sharing"].toMap().contains("api_enabled")) {
|
|
return _capabilities["files_sharing"].toMap()["api_enabled"].toBool();
|
|
} else {
|
|
// This was later added so if it is not present just assume the API is enabled.
|
|
return true;
|
|
}
|
|
}
|
|
|
|
bool Capabilities::sharePublicLink() const
|
|
{
|
|
if (_capabilities["files_sharing"].toMap().contains("public")) {
|
|
return shareAPI() && _capabilities["files_sharing"].toMap()["public"].toMap()["enabled"].toBool();
|
|
} else {
|
|
// This was later added so if it is not present just assume that link sharing is enabled.
|
|
return true;
|
|
}
|
|
}
|
|
|
|
bool Capabilities::sharePublicLinkAllowUpload() const
|
|
{
|
|
return _capabilities["files_sharing"].toMap()["public"].toMap()["upload"].toBool();
|
|
}
|
|
|
|
bool Capabilities::sharePublicLinkEnforcePassword() const
|
|
{
|
|
return _capabilities["files_sharing"].toMap()["public"].toMap()["password"].toMap()["enforced"].toBool();
|
|
}
|
|
|
|
bool Capabilities::sharePublicLinkEnforceExpireDate() const
|
|
{
|
|
return _capabilities["files_sharing"].toMap()["public"].toMap()["expire_date"].toMap()["enforced"].toBool();
|
|
}
|
|
|
|
int Capabilities::sharePublicLinkExpireDateDays() const
|
|
{
|
|
return _capabilities["files_sharing"].toMap()["public"].toMap()["expire_date"].toMap()["days"].toInt();
|
|
}
|
|
|
|
bool Capabilities::shareResharing() const
|
|
{
|
|
return _capabilities["files_sharing"].toMap()["resharing"].toBool();
|
|
}
|
|
|
|
bool Capabilities::notificationsAvailable() const
|
|
{
|
|
// We require the OCS style API in 9.x, can't deal with the REST one only found in 8.2
|
|
return _capabilities.contains("notifications") && _capabilities["notifications"].toMap().contains("ocs-endpoints");
|
|
}
|
|
|
|
bool Capabilities::isValid() const
|
|
{
|
|
return !_capabilities.isEmpty();
|
|
}
|
|
|
|
QList<QByteArray> Capabilities::supportedChecksumTypes() const
|
|
{
|
|
QList<QByteArray> list;
|
|
foreach (const auto & t, _capabilities["checksums"].toMap()["supportedTypes"].toList()) {
|
|
list.push_back(t.toByteArray());
|
|
}
|
|
return list;
|
|
}
|
|
|
|
QByteArray Capabilities::preferredUploadChecksumType() const
|
|
{
|
|
return _capabilities["checksums"].toMap()["preferredUploadType"].toByteArray();
|
|
}
|
|
|
|
QByteArray Capabilities::uploadChecksumType() const
|
|
{
|
|
QByteArray preferred = preferredUploadChecksumType();
|
|
if (!preferred.isEmpty())
|
|
return preferred;
|
|
QList<QByteArray> supported = supportedChecksumTypes();
|
|
if (!supported.isEmpty())
|
|
return supported.first();
|
|
return QByteArray();
|
|
}
|
|
|
|
bool Capabilities::chunkingNg() const
|
|
{
|
|
static const auto chunkng = qgetenv("OWNCLOUD_CHUNKING_NG");
|
|
if (chunkng == "0") return false;
|
|
if (chunkng == "1") return true;
|
|
return _capabilities["dav"].toMap()["chunking"].toByteArray() >= "1.0";
|
|
}
|
|
|
|
|
|
}
|