aboutsummaryrefslogtreecommitdiff
path: root/lib/database.h
diff options
context:
space:
mode:
authorTobias Fella <fella@posteo.de>2021-12-10 16:10:10 +0100
committerTobias Fella <fella@posteo.de>2021-12-10 16:10:31 +0100
commitb4cc38fc7c2c63d8122106a2451aec2c60176a4b (patch)
treea5c18272ce47b7aa08f96e4f8bdeebb7b8a7ea54 /lib/database.h
parent6cec450f1d749936bd51a1471ac0ed74f633ef66 (diff)
downloadlibquotient-b4cc38fc7c2c63d8122106a2451aec2c60176a4b.tar.gz
libquotient-b4cc38fc7c2c63d8122106a2451aec2c60176a4b.zip
Use individual databases for each connection
Diffstat (limited to 'lib/database.h')
-rw-r--r--lib/database.h32
1 files changed, 14 insertions, 18 deletions
diff --git a/lib/database.h b/lib/database.h
index 25af2833..fbb940c8 100644
--- a/lib/database.h
+++ b/lib/database.h
@@ -15,32 +15,28 @@ class Database : public QObject
Q_OBJECT
public:
- static Database &instance()
- {
- static Database _instance;
- return _instance;
- }
+ Database(const QString& matrixId, QObject* parent);
int version();
void transaction();
void commit();
QSqlQuery execute(const QString &queryString);
QSqlQuery execute(QSqlQuery &query);
-
- QByteArray accountPickle(const QString &matrixId);
- void setAccountPickle(const QString &matrixId, const QByteArray &pickle);
- void clear(const QString &matrixId);
- void saveOlmSession(const QString& matrixId, const QString& senderKey, const QString& sessionId, const QByteArray &pickle);
- UnorderedMap<QString, std::vector<QOlmSessionPtr>> loadOlmSessions(const QString& matrixId, const PicklingMode& picklingMode);
- UnorderedMap<QPair<QString, QString>, QOlmInboundGroupSessionPtr> loadMegolmSessions(const QString& matrixId, const QString& roomId, const PicklingMode& picklingMode);
- void saveMegolmSession(const QString& matrixId, const QString& roomId, const QString& senderKey, const QString& sessionKey, const QByteArray& pickle);
- void addGroupSessionIndexRecord(const QString& matrixId, const QString& roomId, const QString& sessionId, uint32_t index, const QString& eventId, qint64 ts);
- QPair<QString, qint64> groupSessionIndexRecord(const QString& matrixId, const QString& roomId, const QString& sessionId, qint64 index);
-
+ QSqlDatabase database();
+ QSqlQuery prepareQuery(const QString& quaryString);
+
+ QByteArray accountPickle();
+ void setAccountPickle(const QByteArray &pickle);
+ void clear();
+ void saveOlmSession(const QString& senderKey, const QString& sessionId, const QByteArray &pickle);
+ UnorderedMap<QString, std::vector<QOlmSessionPtr>> loadOlmSessions(const PicklingMode& picklingMode);
+ UnorderedMap<QPair<QString, QString>, QOlmInboundGroupSessionPtr> loadMegolmSessions(const QString& roomId, const PicklingMode& picklingMode);
+ void saveMegolmSession(const QString& roomId, const QString& senderKey, const QString& sessionKey, const QByteArray& pickle);
+ void addGroupSessionIndexRecord(const QString& roomId, const QString& sessionId, uint32_t index, const QString& eventId, qint64 ts);
+ QPair<QString, qint64> groupSessionIndexRecord(const QString& roomId, const QString& sessionId, qint64 index);
private:
- Database();
-
void migrateTo1();
+ QString m_matrixId;
};
}