- An enforced proxy no longer gets replaced by the operating system proxy. - Saving an account now writes the proxy of the account. - New accounts get the policy when they are created. - Only enforced fields are disabled. - Server values apply only to the account that supplied them. - An enforced virtual files mode of off now also turns off the macOS File Provider. - Out of range proxy values from a device policy are skipped. Assisted-by: Claude Code:claude-opus-5 Signed-off-by: Camila Ayres <[email protected]>
79 lines
2.2 KiB
C++
79 lines
2.2 KiB
C++
/*
|
|
* SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
|
|
* SPDX-License-Identifier: GPL-2.0-or-later
|
|
*/
|
|
|
|
#ifndef MANAGEDSETTINGSTESTUTILS_H
|
|
#define MANAGEDSETTINGSTESTUTILS_H
|
|
|
|
#include <QVariantMap>
|
|
|
|
#include <optional>
|
|
|
|
#include "settings/managedproxysettings.h"
|
|
#include "settings/managedsettings.h"
|
|
|
|
class MapSource : public OCC::SettingSource
|
|
{
|
|
public:
|
|
MapSource(OCC::SettingSourceType kind, OCC::EnforcementState enforcement, int priority, QVariantMap values)
|
|
: _kind(kind)
|
|
, _enforcement(enforcement)
|
|
, _priority(priority)
|
|
, _values(std::move(values))
|
|
{
|
|
}
|
|
|
|
[[nodiscard]] std::optional<QVariant> read(const QString &key, const QString &) const override
|
|
{
|
|
if (!_values.contains(key)) {
|
|
return std::nullopt;
|
|
}
|
|
return _values.value(key);
|
|
}
|
|
[[nodiscard]] OCC::SettingSourceType type() const override
|
|
{
|
|
return _kind;
|
|
}
|
|
[[nodiscard]] OCC::EnforcementState enforcement() const override
|
|
{
|
|
return _enforcement;
|
|
}
|
|
[[nodiscard]] int priority() const override
|
|
{
|
|
return _priority;
|
|
}
|
|
|
|
private:
|
|
OCC::SettingSourceType _kind;
|
|
OCC::EnforcementState _enforcement;
|
|
int _priority;
|
|
QVariantMap _values;
|
|
};
|
|
|
|
inline OCC::ManagedProxySettings
|
|
managedProxyFields(bool enforced, std::optional<int> proxyType, std::optional<QString> proxyHostName, std::optional<int> proxyPort)
|
|
{
|
|
OCC::ManagedProxySettings managedProxy;
|
|
if (proxyType) {
|
|
managedProxy.typeManaged = true;
|
|
managedProxy.typeEnforced = enforced;
|
|
managedProxy.proxyType = *proxyType;
|
|
}
|
|
if (proxyHostName) {
|
|
managedProxy.hostManaged = true;
|
|
managedProxy.hostEnforced = enforced;
|
|
managedProxy.proxyHostName = *proxyHostName;
|
|
}
|
|
if (proxyPort) {
|
|
managedProxy.portManaged = true;
|
|
managedProxy.portEnforced = enforced;
|
|
managedProxy.proxyPort = *proxyPort;
|
|
}
|
|
managedProxy.isManaged = managedProxy.typeManaged || managedProxy.hostManaged || managedProxy.portManaged;
|
|
managedProxy.isEnforced = managedProxy.typeEnforced || managedProxy.hostEnforced || managedProxy.portEnforced;
|
|
return managedProxy;
|
|
}
|
|
|
|
#endif // MANAGEDSETTINGSTESTUTILS_H
|