File indexing completed on 2023-11-26 08:17:53

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