QXmpp Version: 1.4.0
Loading...
Searching...
No Matches
QXmppMessage.h
1/*
2 * Copyright (C) 2008-2021 The QXmpp developers
3 *
4 * Author:
5 * Manjeet Dahiya
6 * Jeremy Lainé
7 * Linus Jahn
8 *
9 * Source:
10 * https://github.com/qxmpp-project/qxmpp
11 *
12 * This file is a part of QXmpp library.
13 *
14 * This library is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU Lesser General Public
16 * License as published by the Free Software Foundation; either
17 * version 2.1 of the License, or (at your option) any later version.
18 *
19 * This library is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
22 * Lesser General Public License for more details.
23 *
24 */
25
26#ifndef QXMPPMESSAGE_H
27#define QXMPPMESSAGE_H
28
29#include "QXmppStanza.h"
30
31// Required for source compatibility
32#include <QDateTime>
33
34#include <optional>
35
36class QXmppMessagePrivate;
39
45class QXMPP_EXPORT QXmppMessage : public QXmppStanza
46{
47public:
49 enum Type {
50 Error = 0,
51 Normal,
52 Chat,
53 GroupChat,
54 Headline
55 };
56
63 enum State {
64 None = 0,
69 Paused
70 };
71
77 enum Marker {
78 NoMarker = 0,
79 Received,
80 Displayed,
81 Acknowledged
82 };
83
89 enum Hint {
90 NoPermanentStore = 1 << 0,
91 NoStore = 1 << 1,
92 NoCopy = 1 << 2,
93 Store = 1 << 3
94 };
95
109 OMEMO
110 };
111
112 QXmppMessage(const QString &from = QString(), const QString &to = QString(),
113 const QString &body = QString(), const QString &thread = QString());
114
116 ~QXmppMessage() override;
117
119
120 bool isXmppStanza() const override;
121
122 QString body() const;
123 void setBody(const QString &);
124
125 QString subject() const;
126 void setSubject(const QString &);
127
128 QString thread() const;
129 void setThread(const QString &);
130
131 QString parentThread() const;
132 void setParentThread(const QString &);
133
134 QXmppMessage::Type type() const;
135 void setType(QXmppMessage::Type);
136
137 // XEP-0066: Out of Band Data
138 QString outOfBandUrl() const;
139 void setOutOfBandUrl(const QString &);
140
141 // XEP-0071: XHTML-IM
142 QString xhtml() const;
143 void setXhtml(const QString &xhtml);
144
145 // XEP-0085: Chat State Notifications
146 QXmppMessage::State state() const;
147 void setState(QXmppMessage::State);
148
149 // XEP-0091: Legacy Delayed Delivery | XEP-0203: Delayed Delivery
150 QDateTime stamp() const;
151 void setStamp(const QDateTime &stamp);
152
153 // XEP-0184: Message Delivery Receipts
154 bool isReceiptRequested() const;
155 void setReceiptRequested(bool requested);
156
157 QString receiptId() const;
158 void setReceiptId(const QString &id);
159
160 // XEP-0224: Attention
161 bool isAttentionRequested() const;
162 void setAttentionRequested(bool requested);
163
164 // XEP-0231: Bits of Binary
165 QXmppBitsOfBinaryDataList bitsOfBinaryData() const;
166 QXmppBitsOfBinaryDataList &bitsOfBinaryData();
167 void setBitsOfBinaryData(const QXmppBitsOfBinaryDataList &bitsOfBinaryData);
168
169 // XEP-0245: The /me Command
170 static bool isSlashMeCommand(const QString &body);
171 bool isSlashMeCommand() const;
172 static QString slashMeCommandText(const QString &body);
173 QString slashMeCommandText() const;
174
175 // XEP-0249: Direct MUC Invitations
176 QString mucInvitationJid() const;
177 void setMucInvitationJid(const QString &jid);
178
179 QString mucInvitationPassword() const;
180 void setMucInvitationPassword(const QString &password);
181
182 QString mucInvitationReason() const;
183 void setMucInvitationReason(const QString &reason);
184
185 // XEP-0280: Message Carbons
186 bool isPrivate() const;
187 void setPrivate(const bool);
188
189 // XEP-0308: Last Message Correction
190 QString replaceId() const;
191 void setReplaceId(const QString &);
192
193 // XEP-0333: Chat State Markers
194 bool isMarkable() const;
195 void setMarkable(const bool);
196
197 QString markedId() const;
198 void setMarkerId(const QString &);
199
200 QString markedThread() const;
201 void setMarkedThread(const QString &);
202
203 Marker marker() const;
204 void setMarker(const Marker);
205
206 // XEP-0334: Message Processing Hints
207 bool hasHint(const Hint hint) const;
208 void addHint(const Hint hint);
209 void removeHint(const Hint hint);
210 void removeAllHints();
211
212 // XEP-0359: Unique and Stable Stanza IDs
213 QString stanzaId() const;
214 void setStanzaId(const QString &id);
215
216 QString stanzaIdBy() const;
217 void setStanzaIdBy(const QString &id);
218
219 QString originId() const;
220 void setOriginId(const QString &id);
221
222 // XEP-0367: Message Attaching
223 QString attachId() const;
224 void setAttachId(const QString &);
225
226 // XEP-0369: Mediated Information eXchange (MIX)
227 QString mixUserJid() const;
228 void setMixUserJid(const QString &);
229
230 QString mixUserNick() const;
231 void setMixUserNick(const QString &);
232
233 // XEP-0380: Explicit Message Encryption
234 EncryptionMethod encryptionMethod() const;
235 void setEncryptionMethod(EncryptionMethod);
236 QString encryptionMethodNs() const;
237 void setEncryptionMethodNs(const QString &);
238
239 QString encryptionName() const;
240 void setEncryptionName(const QString &);
241
242 // XEP-0382: Spoiler messages
243 bool isSpoiler() const;
244 void setIsSpoiler(bool);
245
246 QString spoilerHint() const;
247 void setSpoilerHint(const QString &);
248
249 // XEP-0407: Mediated Information eXchange (MIX): Miscellaneous Capabilities
250 std::optional<QXmppMixInvitation> mixInvitation() const;
251 void setMixInvitation(const std::optional<QXmppMixInvitation> &mixInvitation);
252
253 // XEP-0428: Fallback Indication
254 bool isFallback() const;
255 void setIsFallback(bool isFallback);
256
258 void parse(const QDomElement &element) override;
259 void toXml(QXmlStreamWriter *writer) const override;
261
262private:
263 void parseExtension(const QDomElement &element, QXmppElementList &unknownExtensions);
264 void parseXElement(const QDomElement &element, QXmppElementList &unknownElements);
265
266 QSharedDataPointer<QXmppMessagePrivate> d;
267};
268
269Q_DECLARE_METATYPE(QXmppMessage)
270
271#endif // QXMPPMESSAGE_H
Definition: QXmppBitsOfBinaryDataList.h:40
The QXmppMessage class represents an XMPP message.
Definition: QXmppMessage.h:46
EncryptionMethod
Definition: QXmppMessage.h:103
@ OTR
XEP-0364: Current Off-the-Record Messaging Usage
Definition: QXmppMessage.h:106
@ UnknownEncryption
Unknown encryption.
Definition: QXmppMessage.h:105
@ OX
XEP-0373: OpenPGP for XMPP
Definition: QXmppMessage.h:108
@ NoEncryption
No encryption.
Definition: QXmppMessage.h:104
@ LegacyOpenPGP
XEP-0027: Current Jabber OpenPGP Usage
Definition: QXmppMessage.h:107
QXmppMessage & operator=(const QXmppMessage &other)
Assigns other to this message.
Type
This enum describes a message type.
Definition: QXmppMessage.h:49
Marker
Definition: QXmppMessage.h:77
Hint
Definition: QXmppMessage.h:89
State
Definition: QXmppMessage.h:63
@ Active
User is actively participating in the chat session.
Definition: QXmppMessage.h:65
@ Inactive
User has not been actively participating in the chat session.
Definition: QXmppMessage.h:66
@ Composing
User is composing a message.
Definition: QXmppMessage.h:68
@ Gone
User has effectively ended their participation in the chat session.
Definition: QXmppMessage.h:67
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:43
The Error class represents a stanza error.
Definition: QXmppStanza.h:106
The QXmppStanza class is the base class for all XMPP stanzas.
Definition: QXmppStanza.h:100
virtual bool isXmppStanza() const
Definition: QXmppStanza.cpp:671