6 #include <QtCore/QObject>
7 #include <QtSql/QSqlQuery>
8 #include <QtCore/QVector>
10 #include <QtCore/QHash>
12 #include "e2ee/e2ee_common.h"
18 class QOlmInboundGroupSession;
19 class QOlmOutboundGroupSession;
24 Database(
const QString& userId,
const QString& deviceId,
25 PicklingKey&& picklingKey);
30 QSqlQuery execute(
const QString &queryString);
31 void execute(QSqlQuery &query);
32 QSqlDatabase database()
const;
33 QSqlQuery prepareQuery(
const QString& queryString)
const;
35 void storeOlmAccount(
const QOlmAccount& olmAccount);
36 std::optional<OlmErrorCode> setupOlmAccount(QOlmAccount &olmAccount);
38 void saveOlmSession(
const QByteArray& senderKey,
const QOlmSession& session,
39 const QDateTime& timestamp);
40 std::unordered_map<QByteArray, std::vector<QOlmSession>> loadOlmSessions();
41 std::unordered_map<QByteArray, QOlmInboundGroupSession> loadMegolmSessions(
42 const QString& roomId);
43 void saveMegolmSession(
const QString& roomId,
44 const QOlmInboundGroupSession& session,
45 const QByteArray& senderKey,
46 const QByteArray& senderClaimedEdKey);
47 void addGroupSessionIndexRecord(
const QString& roomId,
48 const QString& sessionId, uint32_t index,
49 const QString& eventId, qint64 ts);
50 std::pair<QString, qint64> groupSessionIndexRecord(
const QString& roomId,
51 const QString& sessionId,
53 void clearRoomData(
const QString& roomId);
54 void setOlmSessionLastReceived(
const QByteArray& sessionId,
55 const QDateTime& timestamp);
56 std::optional<QOlmOutboundGroupSession> loadCurrentOutboundMegolmSession(
const QString& roomId);
57 void saveCurrentOutboundMegolmSession(
58 const QString& roomId,
const QOlmOutboundGroupSession& session);
59 void updateOlmSession(
const QByteArray& senderKey,
60 const QOlmSession& session);
63 QMultiHash<QString, QString> devicesWithoutKey(
64 const QString& roomId, QMultiHash<QString, QString> devices,
65 const QByteArray& sessionId);
67 void setDevicesReceivedKey(
68 const QString& roomId,
69 const QVector<std::tuple<QString, QString, QString>>& devices,
70 const QByteArray& sessionId, uint32_t index);
72 bool isSessionVerified(
const QString& edKey);
73 void setSessionVerified(
const QString& edKeyId);
74 void setMasterKeyVerified(
const QString& masterKey);
76 QString edKeyForKeyId(
const QString& userId,
const QString& edKeyId);
77 void storeEncrypted(
const QString& name,
const QByteArray& key);
78 QByteArray loadEncrypted(
const QString& name);
80 QString userSigningPublicKey();
81 QString selfSigningPublicKey();
83 QString edKeyForMegolmSession(
const QString& sessionId);
84 QString senderKeyForMegolmSession(
const QString& sessionId);
100 PicklingKey m_picklingKey;