2015-07-16 22:49:12 +03:00
|
|
|
/*
|
|
|
|
* 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; version 2 of the License.
|
|
|
|
*
|
|
|
|
* 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"
|
|
|
|
|
2015-10-15 10:54:01 +03:00
|
|
|
#include "configfile.h"
|
|
|
|
|
2015-07-16 22:49:12 +03:00
|
|
|
#include <QVariantMap>
|
|
|
|
|
|
|
|
namespace OCC {
|
|
|
|
|
|
|
|
|
2015-07-29 13:05:00 +03:00
|
|
|
Capabilities::Capabilities(const QVariantMap &capabilities)
|
2015-07-16 22:49:12 +03:00
|
|
|
: _capabilities(capabilities)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-10-06 10:07:45 +03:00
|
|
|
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
|
|
|
|
{
|
|
|
|
return _capabilities["files_sharing"].toMap()["public"].toMap()["enabled"].toBool();
|
|
|
|
}
|
|
|
|
|
2015-08-20 14:39:44 +03:00
|
|
|
bool Capabilities::sharePublicLinkAllowUpload() const
|
|
|
|
{
|
|
|
|
return _capabilities["files_sharing"].toMap()["public"].toMap()["upload"].toBool();
|
|
|
|
}
|
|
|
|
|
2015-10-06 10:07:45 +03:00
|
|
|
bool Capabilities::sharePublicLinkEnforcePassword() const
|
2015-07-16 22:49:12 +03:00
|
|
|
{
|
|
|
|
return _capabilities["files_sharing"].toMap()["public"].toMap()["password"].toMap()["enforced"].toBool();
|
|
|
|
}
|
|
|
|
|
2015-10-06 10:07:45 +03:00
|
|
|
bool Capabilities::sharePublicLinkEnforceExpireDate() const
|
2015-07-16 22:49:12 +03:00
|
|
|
{
|
|
|
|
return _capabilities["files_sharing"].toMap()["public"].toMap()["expire_date"].toMap()["enforced"].toBool();
|
|
|
|
}
|
|
|
|
|
2015-10-06 10:07:45 +03:00
|
|
|
int Capabilities::sharePublicLinkExpireDateDays() const
|
2015-07-16 22:49:12 +03:00
|
|
|
{
|
|
|
|
return _capabilities["files_sharing"].toMap()["public"].toMap()["expire_date"].toMap()["days"].toInt();
|
|
|
|
}
|
|
|
|
|
2015-10-06 10:07:45 +03:00
|
|
|
bool Capabilities::shareResharing() const
|
|
|
|
{
|
|
|
|
return _capabilities["files_sharing"].toMap()["resharing"].toBool();
|
|
|
|
}
|
|
|
|
|
2015-10-28 16:22:29 +03:00
|
|
|
QList<QByteArray> Capabilities::supportedChecksumTypesAdvertised() const
|
2015-10-01 16:00:33 +03:00
|
|
|
{
|
2015-10-14 16:03:40 +03:00
|
|
|
return QList<QByteArray>();
|
2015-10-01 16:00:33 +03:00
|
|
|
}
|
|
|
|
|
2015-10-15 10:54:01 +03:00
|
|
|
QList<QByteArray> Capabilities::supportedChecksumTypes() const
|
|
|
|
{
|
2015-10-28 16:22:29 +03:00
|
|
|
auto list = supportedChecksumTypesAdvertised();
|
2015-10-15 10:54:01 +03:00
|
|
|
QByteArray cfgType = ConfigFile().transmissionChecksum().toLatin1();
|
|
|
|
if (!cfgType.isEmpty()) {
|
|
|
|
list.prepend(cfgType);
|
|
|
|
}
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
QByteArray Capabilities::preferredChecksumType() const
|
|
|
|
{
|
|
|
|
auto list = supportedChecksumTypes();
|
|
|
|
if (list.isEmpty()) {
|
|
|
|
return QByteArray();
|
|
|
|
}
|
|
|
|
return list.first();
|
|
|
|
}
|
|
|
|
|
2015-07-16 22:49:12 +03:00
|
|
|
}
|