Optimize room config

This commit is contained in:
Carl Schwan
2023-09-26 16:28:53 +02:00
committed by Carl Schwan
parent c04d8d6f59
commit 8945e004e2
4 changed files with 87 additions and 8 deletions

View File

@@ -0,0 +1,41 @@
// SPDX-FileCopyrightText: 2023 Carl Schwan <carl@carlschwan.eu>
// SPDX-License-Identifier: LGPL-2.0-or-later
#pragma once
#include <KConfigGroup>
#include <KSharedConfig>
/**
* Store and retrieve the last message of a room.
*/
class RoomLastMessageProvider
{
public:
/**
* Get the global instance of RoomLastMessageProvider.
*/
static RoomLastMessageProvider &self();
~RoomLastMessageProvider();
/**
* Check if we have the last message content for the specified roomId.
*/
bool hasKey(const QString &roomId) const;
/**
* Read the last message content of the specified roomId.
*/
QByteArray read(const QString &roomId) const;
/**
* Write the last message content for the specified roomId.
*/
void write(const QString &roomId, const QByteArray &json);
private:
RoomLastMessageProvider();
KSharedConfig::Ptr m_config;
KConfigGroup m_configGroup;
};