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