aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/connection.cpp11
-rw-r--r--lib/connection.h3
-rw-r--r--lib/room.cpp9
3 files changed, 17 insertions, 6 deletions
diff --git a/lib/connection.cpp b/lib/connection.cpp
index 04ce1dc2..cc5d8739 100644
--- a/lib/connection.cpp
+++ b/lib/connection.cpp
@@ -38,6 +38,7 @@
# include "e2ee/qolmaccount.h"
# include "e2ee/qolmutils.h"
# include "database.h"
+# include "e2ee/qolminboundsession.h"
#if QT_VERSION_MAJOR >= 6
# include <qt6keychain/keychain.h>
@@ -2120,4 +2121,14 @@ Database* Connection::database()
{
return d->database;
}
+
+UnorderedMap<QPair<QString, QString>, QOlmInboundGroupSessionPtr> Connection::loadRoomMegolmSessions(Room* room)
+{
+ return database()->loadMegolmSessions(room->id(), picklingMode());
+}
+
+void Connection::saveMegolmSession(Room* room, const QString& senderKey, QOlmInboundGroupSession* session)
+{
+ database()->saveMegolmSession(room->id(), senderKey, session->sessionId(), session->pickle(picklingMode()));
+}
#endif
diff --git a/lib/connection.h b/lib/connection.h
index 8dec2a0c..13aa15c0 100644
--- a/lib/connection.h
+++ b/lib/connection.h
@@ -50,6 +50,7 @@ class LeaveRoomJob;
class Database;
class QOlmAccount;
+class QOlmInboundGroupSession;
using LoginFlow = GetLoginFlowsJob::LoginFlow;
@@ -315,6 +316,8 @@ public:
#ifdef Quotient_E2EE_ENABLED
QOlmAccount* olmAccount() const;
Database* database();
+ UnorderedMap<QPair<QString, QString>, QOlmInboundGroupSessionPtr> loadRoomMegolmSessions(Room* room);
+ void saveMegolmSession(Room* room, const QString& senderKey, QOlmInboundGroupSession* session);
#endif // Quotient_E2EE_ENABLED
Q_INVOKABLE Quotient::SyncJob* syncJob() const;
Q_INVOKABLE int millisToReconnect() const;
diff --git a/lib/room.cpp b/lib/room.cpp
index a46892f3..492845d7 100644
--- a/lib/room.cpp
+++ b/lib/room.cpp
@@ -370,9 +370,6 @@ public:
// A map from (senderKey, sessionId) to InboundGroupSession
UnorderedMap<QPair<QString, QString>, QOlmInboundGroupSessionPtr> groupSessions;
- void loadMegOlmSessions() {
- groupSessions = q->connection()->database()->loadMegolmSessions(q->id(), q->connection()->picklingMode());
- }
bool addInboundGroupSession(QString senderKey, QString sessionId,
QString sessionKey)
{
@@ -382,14 +379,14 @@ public:
return false;
}
- std::unique_ptr<QOlmInboundGroupSession> megolmSession = QOlmInboundGroupSession::create(sessionKey.toLatin1());
+ auto megolmSession = QOlmInboundGroupSession::create(sessionKey.toLatin1());
if (megolmSession->sessionId() != sessionId) {
qCWarning(E2EE) << "Session ID mismatch in m.room_key event sent "
"from sender with key" << senderKey;
return false;
}
qCWarning(E2EE) << "Adding inbound session";
- q->connection()->database()->saveMegolmSession(q->id(), senderKey, sessionId, megolmSession->pickle(q->connection()->picklingMode()));
+ connection->saveMegolmSession(q, senderKey, megolmSession.get());
groupSessions[{senderKey, sessionId}] = std::move(megolmSession);
return true;
}
@@ -460,7 +457,7 @@ Room::Room(Connection* connection, QString id, JoinState initialJoinState)
connection->encryptionUpdate(this);
}
});
- d->loadMegOlmSessions();
+ d->groupSessions = connection->loadRoomMegolmSessions(this);
connect(this, &Room::beforeDestruction, this, [=](){
connection->database()->clearRoomData(id);