|
|
@ -18,11 +18,12 @@ |
|
|
|
#pragma once |
|
|
|
#pragma once |
|
|
|
|
|
|
|
|
|
|
|
#include <QDir> |
|
|
|
#include <QDir> |
|
|
|
|
|
|
|
#include <QMap> |
|
|
|
#include <json.hpp> |
|
|
|
#include <json.hpp> |
|
|
|
#include <lmdb++.h> |
|
|
|
#include <lmdb++.h> |
|
|
|
#include <mtx/responses.hpp> |
|
|
|
#include <mtx/responses.hpp> |
|
|
|
|
|
|
|
|
|
|
|
class RoomState; |
|
|
|
#include "RoomState.h" |
|
|
|
|
|
|
|
|
|
|
|
//! Used to uniquely identify a list of read receipts.
|
|
|
|
//! Used to uniquely identify a list of read receipts.
|
|
|
|
struct ReadReceiptKey |
|
|
|
struct ReadReceiptKey |
|
|
@ -44,17 +45,19 @@ from_json(const json &j, ReadReceiptKey &key) |
|
|
|
key.room_id = j.at("room_id").get<std::string>(); |
|
|
|
key.room_id = j.at("room_id").get<std::string>(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
class Cache |
|
|
|
class Cache : public QObject |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
Q_OBJECT |
|
|
|
|
|
|
|
|
|
|
|
public: |
|
|
|
public: |
|
|
|
Cache(const QString &userId); |
|
|
|
Cache(const QString &userId, QObject *parent = nullptr); |
|
|
|
|
|
|
|
|
|
|
|
void setState(const QString &nextBatchToken, |
|
|
|
void setState(const QString &nextBatchToken, |
|
|
|
const QMap<QString, QSharedPointer<RoomState>> &states); |
|
|
|
const QMap<QString, QSharedPointer<RoomState>> &states); |
|
|
|
bool isInitialized() const; |
|
|
|
bool isInitialized() const; |
|
|
|
|
|
|
|
|
|
|
|
QString nextBatchToken() const; |
|
|
|
QString nextBatchToken() const; |
|
|
|
QMap<QString, RoomState> states(); |
|
|
|
void states(); |
|
|
|
|
|
|
|
|
|
|
|
using Invites = std::map<std::string, mtx::responses::InvitedRoom>; |
|
|
|
using Invites = std::map<std::string, mtx::responses::InvitedRoom>; |
|
|
|
Invites invites(); |
|
|
|
Invites invites(); |
|
|
@ -86,6 +89,9 @@ public: |
|
|
|
QByteArray image(const QString &url) const; |
|
|
|
QByteArray image(const QString &url) const; |
|
|
|
void saveImage(const QString &url, const QByteArray &data); |
|
|
|
void saveImage(const QString &url, const QByteArray &data); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
signals: |
|
|
|
|
|
|
|
void statesLoaded(QMap<QString, RoomState> states); |
|
|
|
|
|
|
|
|
|
|
|
private: |
|
|
|
private: |
|
|
|
void setNextBatchToken(lmdb::txn &txn, const QString &token); |
|
|
|
void setNextBatchToken(lmdb::txn &txn, const QString &token); |
|
|
|
void insertRoomState(lmdb::txn &txn, |
|
|
|
void insertRoomState(lmdb::txn &txn, |
|
|
|