File indexing completed on 2024-05-26 16:09:08

0001 /*
0002    SPDX-FileCopyrightText: 2020-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "libruqola_private_export.h"
0010 #include "permission.h"
0011 #include <QMap>
0012 #include <QString>
0013 
0014 class LIBRUQOLACORE_TESTS_EXPORT PermissionManager
0015 {
0016 public:
0017     PermissionManager();
0018     ~PermissionManager();
0019 
0020     void parsePermissions(const QJsonObject &replyObject);
0021 
0022     [[nodiscard]] QStringList roles(const QString &permissionId) const;
0023     [[nodiscard]] int permissionCount() const;
0024     [[nodiscard]] bool contains(const QString &permissionId) const;
0025 
0026     [[nodiscard]] bool updatePermission(const QJsonArray &updateArray);
0027     void parseUpdatePermission(const QJsonArray &removeArray);
0028 
0029     [[nodiscard]] const Permission permission(const QString &permissionId) const;
0030 
0031     // Only for debugging permissions. (debug mode)
0032     [[nodiscard]] QVector<Permission> permissions() const;
0033 
0034 private:
0035     [[nodiscard]] bool storePermission(const QString &id);
0036     void parseRemovePermission(const QJsonArray &removeArray);
0037     QMap<QString, Permission> mMapPermissions;
0038 };