QXmpp Version: 1.10.0
QXmppOmemoStorage.h
1// SPDX-FileCopyrightText: 2022 Melvin Keskin <melvo@olomono.de>
2//
3// SPDX-License-Identifier: LGPL-2.1-or-later
4
5#ifndef QXMPPOMEMOSTORAGE_H
6#define QXMPPOMEMOSTORAGE_H
7
8#include "QXmppTask.h"
9#include "qxmppomemo_export.h"
10
11#include <optional>
12
13#include <QDateTime>
14#include <QFuture>
15
16class QXMPPOMEMO_EXPORT QXmppOmemoStorage
17{
18public:
22 struct OwnDevice {
29 uint32_t id = 0;
30
36 QString label;
37
42
47
54 uint32_t latestSignedPreKeyId = 1;
55
62 uint32_t latestPreKeyId = 1;
63 };
64
70 struct Device {
74 QString label;
75
79 QByteArray keyId;
80
84 QByteArray session;
85
92 int unrespondedSentStanzasCount = 0;
93
101 int unrespondedReceivedStanzasCount = 0;
102
109 };
110
118 QDateTime creationDate;
119
123 QByteArray data;
124 };
125
129 struct OmemoData {
133 std::optional<OwnDevice> ownDevice;
134
138 QHash<uint32_t, SignedPreKeyPair> signedPreKeyPairs;
139
143 QHash<uint32_t, QByteArray> preKeyPairs;
144
149 QHash<QString, QHash<uint32_t, Device>> devices;
150 };
151
152 virtual ~QXmppOmemoStorage() = default;
153
155
156 virtual QXmppTask<void> setOwnDevice(const std::optional<OwnDevice> &device) = 0;
157
158 virtual QXmppTask<void> addSignedPreKeyPair(uint32_t keyId, const SignedPreKeyPair &keyPair) = 0;
159 virtual QXmppTask<void> removeSignedPreKeyPair(uint32_t keyId) = 0;
160
161 virtual QXmppTask<void> addPreKeyPairs(const QHash<uint32_t, QByteArray> &keyPairs) = 0;
162 virtual QXmppTask<void> removePreKeyPair(uint32_t keyId) = 0;
163
164 virtual QXmppTask<void> addDevice(const QString &jid, uint32_t deviceId, const Device &device) = 0;
165 virtual QXmppTask<void> removeDevice(const QString &jid, uint32_t deviceId) = 0;
166 virtual QXmppTask<void> removeDevices(const QString &jid) = 0;
167
169};
170
171#endif // QXMPPOMEMOSTORAGE_H
The QXmppOmemoStorage class stores data used by XEP-0384: OMEMO Encryption.
Definition: QXmppOmemoStorage.h:17
virtual QXmppTask< void > addPreKeyPairs(const QHash< uint32_t, QByteArray > &keyPairs)=0
virtual QXmppTask< void > removeSignedPreKeyPair(uint32_t keyId)=0
virtual QXmppTask< OmemoData > allData()=0
virtual QXmppTask< void > removePreKeyPair(uint32_t keyId)=0
virtual QXmppTask< void > addSignedPreKeyPair(uint32_t keyId, const SignedPreKeyPair &keyPair)=0
virtual QXmppTask< void > addDevice(const QString &jid, uint32_t deviceId, const Device &device)=0
virtual QXmppTask< void > setOwnDevice(const std::optional< OwnDevice > &device)=0
virtual QXmppTask< void > removeDevice(const QString &jid, uint32_t deviceId)=0
virtual QXmppTask< void > removeDevices(const QString &jid)=0
virtual QXmppTask< void > resetAll()=0
Definition: QXmppTask.h:62
Definition: QXmppOmemoStorage.h:70
QByteArray keyId
Definition: QXmppOmemoStorage.h:79
QString label
Definition: QXmppOmemoStorage.h:74
QByteArray session
Definition: QXmppOmemoStorage.h:84
QDateTime removalFromDeviceListDate
Definition: QXmppOmemoStorage.h:108
Definition: QXmppOmemoStorage.h:129
QHash< uint32_t, QByteArray > preKeyPairs
Definition: QXmppOmemoStorage.h:143
std::optional< OwnDevice > ownDevice
Definition: QXmppOmemoStorage.h:133
QHash< uint32_t, SignedPreKeyPair > signedPreKeyPairs
Definition: QXmppOmemoStorage.h:138
QHash< QString, QHash< uint32_t, Device > > devices
Definition: QXmppOmemoStorage.h:149
Definition: QXmppOmemoStorage.h:22
QString label
Definition: QXmppOmemoStorage.h:36
QByteArray privateIdentityKey
Definition: QXmppOmemoStorage.h:41
QByteArray publicIdentityKey
Definition: QXmppOmemoStorage.h:46
Definition: QXmppOmemoStorage.h:114
QByteArray data
Definition: QXmppOmemoStorage.h:123
QDateTime creationDate
Definition: QXmppOmemoStorage.h:118