@@ -749,6 +749,8 @@ class Message::Private : public QSharedData {
749
749
QString encryptionProtocol; // XEP-0380
750
750
Message::StanzaId stanzaId; // XEP-0359
751
751
QList<Reference> references; // XEP-0385 and XEP-0372
752
+
753
+ std::optional<QStringList> reactions; // XEP-0444
752
754
};
753
755
754
756
#define MessageD () (d ? d : (d = new Private))
@@ -1096,6 +1098,10 @@ void Message::addReference(const Reference &r) { MessageD()->references.append(r
1096
1098
1097
1099
void Message::setReferences (const QList<Reference> &r) { MessageD ()->references = r; }
1098
1100
1101
+ void Message::setReactions (const QStringList &reactions) { MessageD ()->reactions = reactions; }
1102
+
1103
+ std::optional<QStringList> Message::reactions () const { return d ? d->reactions : QStringList {}; }
1104
+
1099
1105
QString Message::invite () const { return d ? d->invite : QString (); }
1100
1106
1101
1107
void Message::setInvite (const QString &s) { MessageD ()->invite = s; }
@@ -1433,6 +1439,16 @@ Stanza Message::toStanza(Stream *stream) const
1433
1439
s.appendChild (r.toXml (&s.doc ()));
1434
1440
}
1435
1441
1442
+ // XEP-0444
1443
+ auto reactionsNS = QStringLiteral (" urn:xmpp:reactions:0" );
1444
+ if (d->reactions ) {
1445
+ auto e = s.createElement (reactionsNS, QStringLiteral (" reactions" ));
1446
+ for (const QString &reaction : *d->reactions ) {
1447
+ e.appendChild (s.createTextElement (reactionsNS, QStringLiteral (" reaction" ), reaction));
1448
+ }
1449
+ s.appendChild (e);
1450
+ }
1451
+
1436
1452
return s;
1437
1453
}
1438
1454
@@ -1785,6 +1801,20 @@ bool Message::fromStanza(const Stanza &s, bool useTimeZoneOffset, int timeZoneOf
1785
1801
}
1786
1802
}
1787
1803
1804
+ // XEP-0444 message reactions
1805
+ auto reactionStanza
1806
+ = childElementsByTagNameNS (root, " urn:xmpp:reactions:0" , QStringLiteral (" reactions" )).item (0 ).toElement ();
1807
+ if (!reactionStanza.isNull ()) {
1808
+ auto reactionTag = QStringLiteral (" reaction" );
1809
+ QStringList reactions;
1810
+ auto reaction = reactionStanza.firstChildElement (reactionTag);
1811
+ while (!reaction.isNull ()) {
1812
+ reactions.append (reaction.text ().trimmed ());
1813
+ reaction = reaction.nextSiblingElement (reactionTag);
1814
+ }
1815
+ d->reactions = reactions;
1816
+ }
1817
+
1788
1818
return true ;
1789
1819
}
1790
1820
0 commit comments