File indexing completed on 2024-10-13 04:29:58
0001 /* 0002 SPDX-FileCopyrightText: 2023-2024 Laurent Montel <montel.org> 0003 0004 SPDX-License-Identifier: LGPL-2.0-or-later 0005 */ 0006 0007 #pragma once 0008 0009 #include "globaldatabase.h" 0010 #include "libruqolacore_export.h" 0011 #include "messages/message.h" 0012 #include <QString> 0013 #include <QVector> 0014 #include <memory> 0015 class LocalMessageLogger; 0016 class LocalMessageDatabase; 0017 class LocalRoomsDatabase; 0018 class LocalAccountDatabase; 0019 class Message; 0020 class Room; 0021 class LIBRUQOLACORE_EXPORT LocalDatabaseManager 0022 { 0023 public: 0024 LocalDatabaseManager(); 0025 ~LocalDatabaseManager(); 0026 0027 void deleteMessage(const QString &accountName, const QString &roomName, const QString &messageId); 0028 void addMessage(const QString &accountName, const QString &roomName, const Message &m); 0029 0030 void addRoom(const QString &accountName, Room *room); 0031 void deleteRoom(const QString &accountName, const QString &roomId); 0032 0033 void updateTimeStamp(const QString &accountName, const QString &roomName, qint64 timestamp, GlobalDatabase::TimeStampType type); 0034 void removeTimeStamp(const QString &accountName, const QString &roomName, GlobalDatabase::TimeStampType type); 0035 [[nodiscard]] qint64 timeStamp(const QString &accountName, const QString &roomName, GlobalDatabase::TimeStampType type); 0036 0037 [[nodiscard]] QVector<Message> 0038 loadMessages(const QString &accountName, const QString &roomName, qint64 startId, qint64 endId, qint64 numberElements, EmojiManager *emojiManager) const; 0039 0040 void updateAccount(const QString &accountName, const QByteArray &ba, qint64 timeStamp); 0041 void deleteAccount(const QString &accountName); 0042 0043 [[nodiscard]] QByteArray jsonAccount(const QString &accountName); 0044 0045 private: 0046 std::unique_ptr<LocalMessageLogger> mMessageLogger; 0047 std::unique_ptr<LocalMessageDatabase> mMessagesDatabase; 0048 std::unique_ptr<LocalRoomsDatabase> mRoomsDatabase; 0049 std::unique_ptr<LocalAccountDatabase> mAccountDatabase; 0050 std::unique_ptr<GlobalDatabase> mGlobalDatabase; 0051 };