QXmpp Version: 1.6.0
Loading...
Searching...
No Matches
QXmppMessage.h
1// SPDX-FileCopyrightText: 2009 Manjeet Dahiya <manjeetdahiya@gmail.com>
2// SPDX-FileCopyrightText: 2010 Jeremy Lainé <jeremy.laine@m4x.org>
3// SPDX-FileCopyrightText: 2018 Linus Jahn <lnj@kaidan.im>
4// SPDX-FileCopyrightText: 2020 Melvin Keskin <melvo@olomono.de>
5// SPDX-FileCopyrightText: 2023 Tibor Csötönyi <work@taibsu.de>
6//
7// SPDX-License-Identifier: LGPL-2.1-or-later
8
9#ifndef QXMPPMESSAGE_H
10#define QXMPPMESSAGE_H
11
12#include "QXmppFileShare.h"
13#include "QXmppStanza.h"
14
15#include <optional>
16
17// Required for source compatibility
18#include <QDateTime>
19
20class QXmppMessagePrivate;
25#ifdef BUILD_OMEMO
26class QXmppOmemoElement;
27#endif
31
37class QXMPP_EXPORT QXmppMessage : public QXmppStanza
38{
39public:
40#if QXMPP_DEPRECATED_SINCE(1, 5)
42 using EncryptionMethod = QXmpp::EncryptionMethod;
43
44 static const EncryptionMethod NoEncryption = EncryptionMethod::NoEncryption;
45 static const EncryptionMethod UnknownEncryption = EncryptionMethod::UnknownEncryption;
46 static const EncryptionMethod OTR = EncryptionMethod::Otr;
47 static const EncryptionMethod LegacyOpenPGP = EncryptionMethod::LegacyOpenPgp;
48 static const EncryptionMethod OX = EncryptionMethod::Ox;
49 static const EncryptionMethod OMEMO = EncryptionMethod::Omemo0;
51#endif
52
54 enum Type {
55 Error = 0,
56 Normal,
57 Chat,
58 GroupChat,
59 Headline
60 };
61
68 enum State {
69 None = 0,
74 Paused
75 };
76
82 enum Marker {
83 NoMarker = 0,
84 Received,
85 Displayed,
86 Acknowledged
87 };
88
94 enum Hint {
95 NoPermanentStore = 1 << 0,
96 NoStore = 1 << 1,
97 NoCopy = 1 << 2,
98 Store = 1 << 3
99 };
100
101 QXmppMessage(const QString &from = QString(), const QString &to = QString(),
102 const QString &body = QString(), const QString &thread = QString());
103
106 ~QXmppMessage() override;
107
110
111 bool isXmppStanza() const override;
112
113 QString body() const;
114 void setBody(const QString &);
115
116 QString e2eeFallbackBody() const;
117 void setE2eeFallbackBody(const QString &fallbackBody);
118
119 QString subject() const;
120 void setSubject(const QString &);
121
122 QString thread() const;
123 void setThread(const QString &);
124
125 QString parentThread() const;
126 void setParentThread(const QString &);
127
128 QXmppMessage::Type type() const;
129 void setType(QXmppMessage::Type);
130
131 // XEP-0066: Out of Band Data
132 QString outOfBandUrl() const;
133 void setOutOfBandUrl(const QString &);
134
135 QVector<QXmppOutOfBandUrl> outOfBandUrls() const;
136 void setOutOfBandUrls(const QVector<QXmppOutOfBandUrl> &urls);
137
138 // XEP-0071: XHTML-IM
139 QString xhtml() const;
140 void setXhtml(const QString &xhtml);
141
142 // XEP-0085: Chat State Notifications
143 QXmppMessage::State state() const;
144 void setState(QXmppMessage::State);
145
146 // XEP-0091: Legacy Delayed Delivery | XEP-0203: Delayed Delivery
147 QDateTime stamp() const;
148 void setStamp(const QDateTime &stamp);
149
150 // XEP-0184: Message Delivery Receipts
151 bool isReceiptRequested() const;
152 void setReceiptRequested(bool requested);
153
154 QString receiptId() const;
155 void setReceiptId(const QString &id);
156
157 // XEP-0224: Attention
158 bool isAttentionRequested() const;
159 void setAttentionRequested(bool requested);
160
161 // XEP-0231: Bits of Binary
162 QXmppBitsOfBinaryDataList bitsOfBinaryData() const;
163 QXmppBitsOfBinaryDataList &bitsOfBinaryData();
164 void setBitsOfBinaryData(const QXmppBitsOfBinaryDataList &bitsOfBinaryData);
165
166 // XEP-0245: The /me Command
167 static bool isSlashMeCommand(const QString &body);
168 bool isSlashMeCommand() const;
169 static QString slashMeCommandText(const QString &body);
170 QString slashMeCommandText() const;
171
172 // XEP-0249: Direct MUC Invitations
173 QString mucInvitationJid() const;
174 void setMucInvitationJid(const QString &jid);
175
176 QString mucInvitationPassword() const;
177 void setMucInvitationPassword(const QString &password);
178
179 QString mucInvitationReason() const;
180 void setMucInvitationReason(const QString &reason);
181
182 // XEP-0280: Message Carbons
183 bool isPrivate() const;
184 void setPrivate(const bool);
185 bool isCarbonForwarded() const;
186 void setCarbonForwarded(bool);
187
188 // XEP-0308: Last Message Correction
189 QString replaceId() const;
190 void setReplaceId(const QString &);
191
192 // XEP-0333: Chat State Markers
193 bool isMarkable() const;
194 void setMarkable(const bool);
195
196 QString markedId() const;
197 void setMarkerId(const QString &);
198
199 QString markedThread() const;
200 void setMarkedThread(const QString &);
201
202 Marker marker() const;
203 void setMarker(const Marker);
204
205 // XEP-0334: Message Processing Hints
206 bool hasHint(const Hint hint) const;
207 void addHint(const Hint hint);
208 void removeHint(const Hint hint);
209 void removeAllHints();
210
211 // XEP-0353: Jingle Message Initiation
212 std::optional<QXmppJingleMessageInitiationElement> jingleMessageInitiationElement() const;
213 void setJingleMessageInitiationElement(const std::optional<QXmppJingleMessageInitiationElement> &jingleMessageInitiationElement);
214
215 // XEP-0359: Unique and Stable Stanza IDs
216 QString stanzaId() const;
217 void setStanzaId(const QString &id);
218
219 QString stanzaIdBy() const;
220 void setStanzaIdBy(const QString &id);
221
222 QString originId() const;
223 void setOriginId(const QString &id);
224
225 // XEP-0367: Message Attaching
226 QString attachId() const;
227 void setAttachId(const QString &);
228
229 // XEP-0369: Mediated Information eXchange (MIX)
230 QString mixUserJid() const;
231 void setMixUserJid(const QString &);
232
233 QString mixUserNick() const;
234 void setMixUserNick(const QString &);
235
236 // XEP-0380: Explicit Message Encryption
237 QXmpp::EncryptionMethod encryptionMethod() const;
238 void setEncryptionMethod(QXmpp::EncryptionMethod);
239 QString encryptionMethodNs() const;
240 void setEncryptionMethodNs(const QString &);
241
242 QString encryptionName() const;
243 void setEncryptionName(const QString &);
244
245 // XEP-0382: Spoiler messages
246 bool isSpoiler() const;
247 void setIsSpoiler(bool);
248
249 QString spoilerHint() const;
250 void setSpoilerHint(const QString &);
251
252 // XEP-0407: Mediated Information eXchange (MIX): Miscellaneous Capabilities
253 std::optional<QXmppMixInvitation> mixInvitation() const;
254 void setMixInvitation(const std::optional<QXmppMixInvitation> &mixInvitation);
255
256 // XEP-0428: Fallback Indication
257 bool isFallback() const;
258 void setIsFallback(bool isFallback);
259
260 // XEP-0434: Trust Messages (TM)
261 std::optional<QXmppTrustMessageElement> trustMessageElement() const;
262 void setTrustMessageElement(const std::optional<QXmppTrustMessageElement> &trustMessageElement);
263
264 // XEP-0444: Message Reactions
265 std::optional<QXmppMessageReaction> reaction() const;
266 void setReaction(const std::optional<QXmppMessageReaction> &reaction);
267
268 // XEP-0447: Stateless file sharing
269 const QVector<QXmppFileShare> &sharedFiles() const;
270 void setSharedFiles(const QVector<QXmppFileShare> &sharedFiles);
271
272 // XEP-0482: Call Invites
273 std::optional<QXmppCallInviteElement> callInviteElement() const;
274 void setCallInviteElement(std::optional<QXmppCallInviteElement> callInviteElement);
275
277#ifdef BUILD_OMEMO
278 // XEP-0384: OMEMO Encryption
279 std::optional<QXmppOmemoElement> omemoElement() const;
280 void setOmemoElement(const std::optional<QXmppOmemoElement> &omemoElement);
281#endif
282
283 void parse(const QDomElement &element) override final;
284 virtual void parse(const QDomElement &element, QXmpp::SceMode);
285 void toXml(QXmlStreamWriter *writer) const override final;
286 virtual void toXml(QXmlStreamWriter *writer, QXmpp::SceMode) const;
288
289 void parseExtensions(const QDomElement &element, QXmpp::SceMode sceMode);
290 virtual bool parseExtension(const QDomElement &element, QXmpp::SceMode);
291 virtual void serializeExtensions(QXmlStreamWriter *writer, QXmpp::SceMode, const QString &baseNamespace = {}) const;
292
293private:
294 QSharedDataPointer<QXmppMessagePrivate> d;
295};
296
297Q_DECLARE_METATYPE(QXmppMessage)
298
299#endif // QXMPPMESSAGE_H
Definition QXmppBitsOfBinaryDataList.h:16
The QXmppCallInviteElement class represents a Call Invite element as specified by XEP-0482: Call Invi...
Definition QXmppJingleData.h:662
The QXmppJingleMessageInitiationElement class represents a Jingle Message Initiation element as speci...
Definition QXmppJingleData.h:615
The QXmppMessageReaction class represents a reaction to a message in the form of emojis as specified ...
Definition QXmppMessageReaction.h:17
The QXmppMessage class represents an XMPP message.
Definition QXmppMessage.h:38
QXmppMessage & operator=(QXmppMessage &&)
Move-assignment operator.
QXmppMessage & operator=(const QXmppMessage &other)
Assignment operator.
Type
This enum describes a message type.
Definition QXmppMessage.h:54
QXmppMessage(QXmppMessage &&)
Move-constructor.
Marker
Definition QXmppMessage.h:82
Hint
Definition QXmppMessage.h:94
State
Definition QXmppMessage.h:68
@ Active
User is actively participating in the chat session.
Definition QXmppMessage.h:70
@ Inactive
User has not been actively participating in the chat session.
Definition QXmppMessage.h:71
@ Composing
User is composing a message.
Definition QXmppMessage.h:73
@ Gone
User has effectively ended their participation in the chat session.
Definition QXmppMessage.h:72
QXmppMessage(const QXmppMessage &other)
Constructs a copy of other.
The QXmppMixInvitation class is used to invite a user to a XEP-0369: Mediated Information eXchange (M...
Definition QXmppMixInvitation.h:24
Definition QXmppOutOfBandUrl.h:19
The Error class represents a stanza error.
Definition QXmppStanza.h:94
The QXmppStanza class is the base class for all XMPP stanzas.
Definition QXmppStanza.h:88
The QXmppTrustMessageElement class represents a trust message element as defined by XEP-0434: Trust M...
Definition QXmppTrustMessageElement.h:18
SceMode
Definition QXmppGlobal.h:136
EncryptionMethod
Definition QXmppGlobal.h:89