QXmpp: QXmppOmemoStorage.h Source File

QXmpp Version: 1.14.4

Loading...
Searching...
No Matches
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
16 class QXMPPOMEMO_EXPORT QXmppOmemoStorage
17{
18public:
22 struct OwnDevice {
29 uint32_t id = 0;
30
36 QString label;
37
41 QByteArray privateIdentityKey;
42
46 QByteArray publicIdentityKey;
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
108 QDateTime removalFromDeviceListDate;
109 };
110
114 struct SignedPreKeyPair {
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
154 virtual QXmppTask<OmemoData> allData() = 0;
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
168 virtual QXmppTask<void> resetAll() = 0;
169};
170
171#endif // QXMPPOMEMOSTORAGE_H
QXmppOmemoStorage
The QXmppOmemoStorage class stores data used by XEP-0384: OMEMO Encryption.
Definition QXmppOmemoStorage.h:17
QXmppOmemoStorage::removePreKeyPair
virtual QXmppTask< void > removePreKeyPair(uint32_t keyId)=0
QXmppOmemoStorage::removeDevice
virtual QXmppTask< void > removeDevice(const QString &jid, uint32_t deviceId)=0
QXmppOmemoStorage::addDevice
virtual QXmppTask< void > addDevice(const QString &jid, uint32_t deviceId, const Device &device)=0
QXmppOmemoStorage::setOwnDevice
virtual QXmppTask< void > setOwnDevice(const std::optional< OwnDevice > &device)=0
QXmppOmemoStorage::removeDevices
virtual QXmppTask< void > removeDevices(const QString &jid)=0
QXmppOmemoStorage::addSignedPreKeyPair
virtual QXmppTask< void > addSignedPreKeyPair(uint32_t keyId, const SignedPreKeyPair &keyPair)=0
QXmppOmemoStorage::resetAll
virtual QXmppTask< void > resetAll()=0
QXmppOmemoStorage::removeSignedPreKeyPair
virtual QXmppTask< void > removeSignedPreKeyPair(uint32_t keyId)=0
QXmppOmemoStorage::allData
virtual QXmppTask< OmemoData > allData()=0
QXmppOmemoStorage::addPreKeyPairs
virtual QXmppTask< void > addPreKeyPairs(const QHash< uint32_t, QByteArray > &keyPairs)=0
QXmppTask
Definition QXmppTask.h:46
QXmppOmemoStorage::Device
Definition QXmppOmemoStorage.h:70
QXmppOmemoStorage::Device::keyId
QByteArray keyId
Definition QXmppOmemoStorage.h:79
QXmppOmemoStorage::Device::unrespondedSentStanzasCount
int unrespondedSentStanzasCount
Definition QXmppOmemoStorage.h:92
QXmppOmemoStorage::Device::unrespondedReceivedStanzasCount
int unrespondedReceivedStanzasCount
Definition QXmppOmemoStorage.h:101
QXmppOmemoStorage::Device::label
QString label
Definition QXmppOmemoStorage.h:74
QXmppOmemoStorage::Device::session
QByteArray session
Definition QXmppOmemoStorage.h:84
QXmppOmemoStorage::Device::removalFromDeviceListDate
QDateTime removalFromDeviceListDate
Definition QXmppOmemoStorage.h:108
QXmppOmemoStorage::OmemoData
Definition QXmppOmemoStorage.h:129
QXmppOmemoStorage::OmemoData::preKeyPairs
QHash< uint32_t, QByteArray > preKeyPairs
Definition QXmppOmemoStorage.h:143
QXmppOmemoStorage::OmemoData::ownDevice
std::optional< OwnDevice > ownDevice
Definition QXmppOmemoStorage.h:133
QXmppOmemoStorage::OmemoData::signedPreKeyPairs
QHash< uint32_t, SignedPreKeyPair > signedPreKeyPairs
Definition QXmppOmemoStorage.h:138
QXmppOmemoStorage::OmemoData::devices
QHash< QString, QHash< uint32_t, Device > > devices
Definition QXmppOmemoStorage.h:149
QXmppOmemoStorage::OwnDevice
Definition QXmppOmemoStorage.h:22
QXmppOmemoStorage::OwnDevice::latestPreKeyId
uint32_t latestPreKeyId
Definition QXmppOmemoStorage.h:62
QXmppOmemoStorage::OwnDevice::latestSignedPreKeyId
uint32_t latestSignedPreKeyId
Definition QXmppOmemoStorage.h:54
QXmppOmemoStorage::OwnDevice::label
QString label
Definition QXmppOmemoStorage.h:36
QXmppOmemoStorage::OwnDevice::privateIdentityKey
QByteArray privateIdentityKey
Definition QXmppOmemoStorage.h:41
QXmppOmemoStorage::OwnDevice::publicIdentityKey
QByteArray publicIdentityKey
Definition QXmppOmemoStorage.h:46
QXmppOmemoStorage::SignedPreKeyPair
Definition QXmppOmemoStorage.h:114
QXmppOmemoStorage::SignedPreKeyPair::data
QByteArray data
Definition QXmppOmemoStorage.h:123
QXmppOmemoStorage::SignedPreKeyPair::creationDate
QDateTime creationDate
Definition QXmppOmemoStorage.h:118