File indexing completed on 2024-09-29 07:24:46
0001 // SPDX-FileCopyrightText: 2023 Carl Schwan <carl@carlschwan.eu> 0002 // SPDX-License-Identifier: LGPL-2.0-or-later 0003 0004 #include "roomlastmessageprovider.h" 0005 0006 using namespace Qt::Literals::StringLiterals; 0007 0008 RoomLastMessageProvider::RoomLastMessageProvider() 0009 : m_config(KSharedConfig::openStateConfig()) 0010 , m_configGroup(KConfigGroup(m_config, u"EventCache"_s)) 0011 { 0012 } 0013 0014 RoomLastMessageProvider::~RoomLastMessageProvider() 0015 { 0016 m_config->sync(); 0017 } 0018 0019 RoomLastMessageProvider &RoomLastMessageProvider::self() 0020 { 0021 static RoomLastMessageProvider instance; 0022 return instance; 0023 } 0024 0025 bool RoomLastMessageProvider::hasKey(const QString &roomId) const 0026 { 0027 return m_configGroup.hasKey(roomId); 0028 } 0029 0030 QByteArray RoomLastMessageProvider::read(const QString &roomId) const 0031 { 0032 return m_configGroup.readEntry(roomId, QByteArray{}); 0033 } 0034 0035 void RoomLastMessageProvider::write(const QString &roomId, const QByteArray &json) 0036 { 0037 m_configGroup.writeEntry(roomId, json); 0038 }