From 458a0472bd0c6ea0a859c5e55ba5dd3d92ecec99 Mon Sep 17 00:00:00 2001 From: Tobias Fella Date: Sat, 26 Feb 2022 18:55:11 +0100 Subject: Add convenience functions for querying user devices and keys from cache --- lib/connection.cpp | 16 ++++++++++++++++ lib/connection.h | 4 ++++ 2 files changed, 20 insertions(+) diff --git a/lib/connection.cpp b/lib/connection.cpp index 66df1e43..ec1c13f5 100644 --- a/lib/connection.cpp +++ b/lib/connection.cpp @@ -2154,4 +2154,20 @@ void Connection::saveMegolmSession(Room* room, const QString& senderKey, QOlmInb { database()->saveMegolmSession(room->id(), senderKey, session->sessionId(), session->pickle(picklingMode())); } + +QStringList Connection::devicesForUser(User* user) const +{ + return d->deviceKeys[user->id()].keys(); +} + +QString Connection::curveKeyForUserDevice(const QString& user, const QString& device) const +{ + return d->deviceKeys[user][device].keys[QStringLiteral("curve25519:") + device]; +} + +QString Connection::edKeyForUserDevice(const QString& user, const QString& device) const +{ + return d->deviceKeys[user][device].keys[QStringLiteral("ed25519:") + device]; +} + #endif diff --git a/lib/connection.h b/lib/connection.h index 165d8d68..4a475319 100644 --- a/lib/connection.h +++ b/lib/connection.h @@ -680,6 +680,10 @@ public Q_SLOTS: void encryptionUpdate(Room *room); PicklingMode picklingMode() const; QJsonObject decryptNotification(const QJsonObject ¬ification); + + QStringList devicesForUser(User* user) const; + QString curveKeyForUserDevice(const QString &user, const QString& device) const; + QString edKeyForUserDevice(const QString& user, const QString& device) const; #endif Q_SIGNALS: /// \brief Initial server resolution has failed -- cgit v1.2.3