File indexing completed on 2024-04-28 16:11:09

0001 /*
0002 
0003  * SPDX-FileCopyrightText: 2016 Riccardo Iaconelli <riccardo@kde.org>
0004  * SPDX-FileCopyrightText: 2018-2024 Laurent Montel <montel@kde.org>
0005  *
0006  * SPDX-License-Identifier: LGPL-2.0-or-later
0007  *
0008  */
0009 
0010 #pragma once
0011 
0012 #include "attachments/file.h"
0013 #include "libruqolacore_export.h"
0014 #include "messages/message.h"
0015 #include "user.h"
0016 #include <QObject>
0017 
0018 class RocketChatAccount;
0019 class LIBRUQOLACORE_EXPORT RocketChatBackend : public QObject
0020 {
0021     Q_OBJECT
0022 public:
0023     explicit RocketChatBackend(RocketChatAccount *account, QObject *parent = nullptr);
0024     ~RocketChatBackend() override;
0025 
0026     /**
0027      * @brief Adds incoming message from server to appropriate room
0028      *
0029      * @param messages The Json containing the message
0030      */
0031     void processIncomingMessages(const QJsonArray &messages, bool loadHistory, bool restApi = false);
0032 
0033     void clearUsersList();
0034 
0035     [[nodiscard]] QVector<User> users() const;
0036 
0037     void clearFilesList();
0038     [[nodiscard]] QVector<File> files() const;
0039 
0040     void loadPublicSettingsAdministrator(qint64 timeStamp = -1);
0041 
0042     void addMessagesFromLocalDataBase(const QVector<Message> &messages);
0043 
0044     void removeMessageFromLocalDatabase(const QStringList &messageIds, const QString &roomId);
0045 
0046     void loadPublicSettings(qint64 timeStamp = -1);
0047 
0048 private:
0049     Q_DISABLE_COPY(RocketChatBackend)
0050     LIBRUQOLACORE_NO_EXPORT void slotRemoved(const QJsonObject &object);
0051     LIBRUQOLACORE_NO_EXPORT void slotAdded(const QJsonObject &object);
0052     LIBRUQOLACORE_NO_EXPORT void slotChanged(const QJsonObject &object);
0053     LIBRUQOLACORE_NO_EXPORT void slotLoginStatusChanged();
0054     LIBRUQOLACORE_NO_EXPORT void slotConnectedChanged();
0055     LIBRUQOLACORE_NO_EXPORT void slotUserIDChanged();
0056     LIBRUQOLACORE_NO_EXPORT void slotGetServerInfoFailed(bool useDeprecatedVersion);
0057     LIBRUQOLACORE_NO_EXPORT void parseServerVersionDone(const QString &version);
0058     LIBRUQOLACORE_NO_EXPORT void tryAutoLogin();
0059     LIBRUQOLACORE_NO_EXPORT void slotPrivateInfoDone(const QJsonObject &data);
0060     LIBRUQOLACORE_NO_EXPORT void updateVideoConferenceInfo(const Message &m);
0061 
0062     QVector<User> mUsers;
0063     QVector<File> mFiles;
0064     RocketChatAccount *mRocketChatAccount = nullptr;
0065 };