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