File indexing completed on 2024-12-22 04:45:15

0001 /*
0002    SPDX-FileCopyrightText: 2018-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #pragma once
0008 
0009 #include "channelgroupbasejob.h"
0010 #include "librocketchatrestapi-qt_export.h"
0011 namespace RocketChatRestApi
0012 {
0013 class LIBROCKETCHATRESTAPI_QT_EXPORT ChannelHistoryJob : public ChannelGroupBaseJob
0014 {
0015     Q_OBJECT
0016 public:
0017     enum ChannelType {
0018         Channel = 0,
0019         Groups,
0020         Direct,
0021         Unknown,
0022     };
0023     Q_ENUM(ChannelType)
0024 
0025     struct LIBROCKETCHATRESTAPI_QT_EXPORT ChannelHistoryInfo {
0026         QString roomId;
0027         QString latestMessage;
0028         QString oldestMessage;
0029         ChannelType channelType = Unknown;
0030         int offset = -1; // default
0031         int count = -1;
0032         bool inclusive = false; // Default
0033         bool unreads = false;
0034     };
0035 
0036     explicit ChannelHistoryJob(QObject *parent = nullptr);
0037     ~ChannelHistoryJob() override;
0038 
0039     [[nodiscard]] bool start() override;
0040     [[nodiscard]] bool requireHttpAuthentication() const override;
0041     [[nodiscard]] bool canStart() const override;
0042 
0043     [[nodiscard]] QNetworkRequest request() const override;
0044 
0045     [[nodiscard]] ChannelHistoryInfo channelHistoryInfo() const;
0046     void setChannelHistoryInfo(const ChannelHistoryInfo &channelHistoryInfo);
0047 
0048 Q_SIGNALS:
0049     void channelHistoryDone(const QJsonObject &obj, const RocketChatRestApi::ChannelGroupBaseJob::ChannelGroupInfo &channelInfo);
0050 
0051 private:
0052     Q_DISABLE_COPY(ChannelHistoryJob)
0053     LIBROCKETCHATRESTAPI_QT_NO_EXPORT void onGetRequestResponse(const QString &replyErrorString, const QJsonDocument &replyJson) override;
0054     ChannelHistoryInfo mChannelHistoryInfo;
0055 };
0056 }
0057 Q_DECLARE_METATYPE(RocketChatRestApi::ChannelHistoryJob::ChannelHistoryInfo)
0058 Q_DECLARE_TYPEINFO(RocketChatRestApi::ChannelHistoryJob::ChannelHistoryInfo, Q_RELOCATABLE_TYPE);
0059 LIBROCKETCHATRESTAPI_QT_EXPORT QDebug operator<<(QDebug d, const RocketChatRestApi::ChannelHistoryJob::ChannelHistoryInfo &t);