File indexing completed on 2024-07-21 12:42:25

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 "libruqola_private_export.h"
0010 #include "rocketchataccount.h"
0011 #include <QObject>
0012 class LIBRUQOLACORE_TESTS_EXPORT ManageChannels : public QObject
0013 {
0014     Q_OBJECT
0015 public:
0016     enum SearchChannelFound {
0017         NoFound = 0,
0018         ChannelOpened,
0019         ChannelHidden,
0020     };
0021     explicit ManageChannels(RocketChatAccount *account, QObject *parent = nullptr);
0022     ~ManageChannels() override;
0023 
0024     void openPrivateGroup(const QString &roomId, RocketChatAccount::ChannelTypeInfo typeInfo);
0025     void openChannel(const QString &roomId, RocketChatAccount::ChannelTypeInfo typeInfo);
0026 
0027     void channelJoin(const RocketChatRestApi::ChannelGroupBaseJob::ChannelGroupInfo &channelInfo, const QString &joinCode);
0028 Q_SIGNALS:
0029     // TODO ?
0030     void selectRoomByRoomIdRequested(const QString &identifier, const QString &messageId = QString());
0031     void selectRoomByRoomNameRequested(const QString &identifier);
0032     void missingChannelPassword(const RocketChatRestApi::ChannelGroupBaseJob::ChannelGroupInfo &channelInfo);
0033     void openArchivedRoom(const RocketChatRestApi::ChannelGroupBaseJob::ChannelGroupInfo &channelInfo);
0034 
0035 private:
0036     void setChannelJoinDone(const RocketChatRestApi::ChannelGroupBaseJob::ChannelGroupInfo &channelInfo);
0037     [[nodiscard]] SearchChannelFound searchOpenChannels(const QString &roomId);
0038     [[nodiscard]] RocketChatRestApi::ChannelGroupBaseJob::ChannelGroupInfo generateGroupInfo(const QString &roomId,
0039                                                                                              RocketChatAccount::ChannelTypeInfo typeInfo);
0040     RocketChatAccount *const mAccount;
0041 };