File indexing completed on 2025-02-02 04:51:46
0001 /* 0002 SPDX-FileCopyrightText: 2021-2024 Laurent Montel <montel@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include "librocketchatrestapi-qt_export.h" 0010 #include "restapiabstractjob.h" 0011 namespace RocketChatRestApi 0012 { 0013 class LIBROCKETCHATRESTAPI_QT_EXPORT SaveRoomSettingsJob : public RestApiAbstractJob 0014 { 0015 Q_OBJECT 0016 public: 0017 struct LIBROCKETCHATRESTAPI_QT_EXPORT SaveRoomSettingsInfo { 0018 enum SettingChanged { 0019 Unknown = 0, 0020 SystemMessages = 1, 0021 RoomName = 2, 0022 RoomTopic = 4, 0023 RoomAnnouncement = 8, 0024 RoomDescription = 16, 0025 RetentionEnabled = 32, 0026 RetentionExcludePinned = 64, 0027 RetentionFilesOnly = 128, 0028 RetentionIgnoreThreads = 256, 0029 RetentionOverrideGlobal = 512, 0030 RetentionMaxAge = 1024, 0031 Favorite = 2048, 0032 RoomType = 4096, 0033 JoinCode = 8192, 0034 ReadOnly = 16384, 0035 Encrypted = 32768, 0036 RoomAvatar = 65536, 0037 ReactWhenReadOnly = 131072, 0038 Featured = 262144, 0039 DefaultValue = 524288, 0040 }; 0041 Q_DECLARE_FLAGS(SettingsChanged, SettingChanged) 0042 0043 QStringList systemMessages; 0044 QString roomAvatar; 0045 QString roomId; 0046 QString roomName; 0047 QString roomTopic; 0048 QString roomAnnouncement; 0049 QString roomDescription; 0050 QString roomType; 0051 QString joinCode; 0052 bool retentionEnabled = false; 0053 bool retentionExcludePinned = false; 0054 bool retentionFilesOnly = false; 0055 bool retentionIgnoreThreads = false; 0056 bool retentionOverrideGlobal = false; 0057 bool favorite = false; 0058 bool readOnly = false; 0059 bool encrypted = false; 0060 bool reactWhenReadOnly = false; 0061 bool featured = false; 0062 bool defaultValue = false; 0063 int retentionMaxAge = 32; 0064 //'featured','roomCustomFields', 0065 //'reactWhenReadOnly', 'default','tokenpass', 'streamingOptions' 0066 SettingsChanged mSettingsWillBeChanged = SettingChanged::Unknown; 0067 [[nodiscard]] bool isValid() const; 0068 }; 0069 0070 explicit SaveRoomSettingsJob(QObject *parent = nullptr); 0071 ~SaveRoomSettingsJob() override; 0072 0073 [[nodiscard]] bool start() override; 0074 [[nodiscard]] bool requireHttpAuthentication() const override; 0075 [[nodiscard]] bool canStart() const override; 0076 [[nodiscard]] QNetworkRequest request() const override; 0077 0078 [[nodiscard]] QJsonDocument json() const; 0079 0080 [[nodiscard]] SaveRoomSettingsInfo saveRoomSettingsInfo() const; 0081 void setSaveRoomSettingsInfo(const SaveRoomSettingsInfo &saveRoomSettingsInfo); 0082 0083 protected: 0084 [[nodiscard]] QString errorMessage(const QString &str, const QJsonObject &detail) override; 0085 0086 Q_SIGNALS: 0087 void saveRoomSettingsDone(const QString &roomId); 0088 0089 private: 0090 Q_DISABLE_COPY(SaveRoomSettingsJob) 0091 LIBROCKETCHATRESTAPI_QT_NO_EXPORT void onPostRequestResponse(const QString &replyErrorString, const QJsonDocument &replyJson) override; 0092 0093 SaveRoomSettingsInfo mSaveRoomSettingsInfo; 0094 }; 0095 } 0096 Q_DECLARE_METATYPE(RocketChatRestApi::SaveRoomSettingsJob::SaveRoomSettingsInfo::SettingChanged) 0097 Q_DECLARE_TYPEINFO(RocketChatRestApi::SaveRoomSettingsJob::SaveRoomSettingsInfo, Q_RELOCATABLE_TYPE); 0098 LIBROCKETCHATRESTAPI_QT_EXPORT QDebug operator<<(QDebug d, const RocketChatRestApi::SaveRoomSettingsJob::SaveRoomSettingsInfo &t);