aboutsummaryrefslogtreecommitdiff
path: root/src/omemo/QXmppOmemoManager.cpp
diff options
context:
space:
mode:
authorLinus Jahn <lnj@kaidan.im>2022-12-28 21:09:12 +0100
committerLinus Jahn <lnj@kaidan.im>2022-12-28 21:17:12 +0100
commitfbc852112728a54c9729a6d9f12e3fd430cabf1e (patch)
tree0414dbf87bab67f240d6480aebe2ac83ebca9c2f /src/omemo/QXmppOmemoManager.cpp
parent5365018c35e0a496376bde9bf7e4bb4e9df6de2a (diff)
downloadqxmpp-fbc852112728a54c9729a6d9f12e3fd430cabf1e.tar.gz
PubSubEvent: Split up Items type into Items and virtual Retract type
This makes the handling much easier because you don't have to manually check whether the set 'Items' type means items have been published or retracted. There is no retract type in the XML representation, but that doesn't mean that we cannot distinguish both cases. Closes #521.
Diffstat (limited to 'src/omemo/QXmppOmemoManager.cpp')
-rw-r--r--src/omemo/QXmppOmemoManager.cpp41
1 files changed, 19 insertions, 22 deletions
diff --git a/src/omemo/QXmppOmemoManager.cpp b/src/omemo/QXmppOmemoManager.cpp
index 1f26ee16..856e00a5 100644
--- a/src/omemo/QXmppOmemoManager.cpp
+++ b/src/omemo/QXmppOmemoManager.cpp
@@ -1259,35 +1259,32 @@ bool Manager::handlePubSubEvent(const QDomElement &element, const QString &pubSu
event.parse(element);
switch (event.eventType()) {
- // Items are published or deleted.
+ // Items have been published.
case QXmppPubSubEventBase::Items: {
- // If there are IDs of deleted items, check for an inconsistency.
- // Otherwise, check for published items.
- if (const auto retractIds = event.retractIds(); !retractIds.isEmpty()) {
- // Specific items are deleted.
- const auto &retractedItem = event.retractIds().constFirst();
- if (retractedItem == QXmppPubSubManager::standardItemIdToString(QXmppPubSubManager::Current)) {
+ const auto items = event.items();
+
+ // Only process items if the event notification contains one.
+ // That is necessary because PubSub allows publishing without
+ // items leading to notification-only events.
+ if (!items.isEmpty()) {
+ const auto &deviceListItem = items.constFirst();
+ if (deviceListItem.id() == QXmppPubSubManager::standardItemIdToString(QXmppPubSubManager::Current)) {
+ d->updateDevices(pubSubService, event.items().constFirst());
+ } else {
d->handleIrregularDeviceListChanges(pubSubService);
}
- } else {
- const auto items = event.items();
-
- // Only process items if the event notification contains one.
- // That is necessary because PubSub allows publishing without
- // items leading to notification-only events.
- if (!items.isEmpty()) {
- const auto &deviceListItem = items.constFirst();
- if (deviceListItem.id() == QXmppPubSubManager::standardItemIdToString(QXmppPubSubManager::Current)) {
- d->updateDevices(pubSubService, event.items().constFirst());
- } else {
- d->handleIrregularDeviceListChanges(pubSubService);
- }
- }
}
break;
}
-
+ // Items have been retracted.
+ case QXmppPubSubEventBase::Retract: {
+ // Specific items are deleted.
+ const auto &retractedItem = event.retractIds().constFirst();
+ if (retractedItem == QXmppPubSubManager::standardItemIdToString(QXmppPubSubManager::Current)) {
+ d->handleIrregularDeviceListChanges(pubSubService);
+ }
+ }
// All items are deleted.
case QXmppPubSubEventBase::Purge:
// The whole node is deleted.