Skip to content
This repository was archived by the owner on Mar 20, 2025. It is now read-only.
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 17 additions & 14 deletions src/omemo/QXmppOmemoManager_p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3140,13 +3140,7 @@ QXmppTask<bool> ManagerPrivate::resetOwnDevice()
if (isDeviceElementDeleted) {
deleteDeviceBundle([=, this](bool isDeviceBundleDeleted) mutable {
if (isDeviceBundleDeleted) {
ownDevice = {};
preKeyPairs.clear();
signedPreKeyPairs.clear();
deviceBundle = {};
devices.clear();

Q_EMIT q->allDevicesRemoved();
resetCachedData();
}

interface.finish(std::move(isDeviceBundleDeleted));
Expand All @@ -3171,6 +3165,7 @@ QXmppTask<void> QXmppOmemoManagerPrivate::resetOwnDeviceLocally()
future.then(q, [this, interface]() mutable {
auto future = omemoStorage->resetAll();
future.then(q, [this, interface]() mutable {
resetCachedData();
interface.finish();
});
});
Expand All @@ -3190,13 +3185,7 @@ QXmppTask<bool> ManagerPrivate::resetAll()
if (isDevicesNodeDeleted) {
deleteNode(ns_omemo_2_bundles.toString(), [this, interface](bool isBundlesNodeDeleted) mutable {
if (isBundlesNodeDeleted) {
ownDevice = {};
preKeyPairs.clear();
signedPreKeyPairs.clear();
deviceBundle = {};
devices.clear();

Q_EMIT q->allDevicesRemoved();
resetCachedData();
}

interface.finish(std::move(isBundlesNodeDeleted));
Expand All @@ -3210,6 +3199,20 @@ QXmppTask<bool> ManagerPrivate::resetAll()
return interface.task();
}

//
// Resets all cached OMEMO data.
//
void ManagerPrivate::resetCachedData()
{
ownDevice = {};
preKeyPairs.clear();
signedPreKeyPairs.clear();
deviceBundle = {};
devices.clear();

Q_EMIT q->allDevicesRemoved();
}

//
// Builds a new session for a new received device if that is enabled.
//
Expand Down
1 change: 1 addition & 0 deletions src/omemo/QXmppOmemoManager_p.h
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,7 @@ class QXmppOmemoManagerPrivate
QXmppTask<bool> resetOwnDevice();
QXmppTask<void> resetOwnDeviceLocally();
QXmppTask<bool> resetAll();
void resetCachedData();

QXmppTask<bool> buildSessionForNewDevice(const QString &jid, uint32_t deviceId, QXmppOmemoStorage::Device &device);
QXmppTask<bool> buildSessionWithDeviceBundle(const QString &jid, uint32_t deviceId, QXmppOmemoStorage::Device &device);
Expand Down
Loading