QXmpp  Version:1.3.1
QXmppMessage.h
1 /*
2  * Copyright (C) 2008-2020 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 // Required for source compatibility
30 #include "QXmppStanza.h"
31 
32 #include <QDateTime>
33 
34 class QXmppMessagePrivate;
36 
42 class QXMPP_EXPORT QXmppMessage : public QXmppStanza
43 {
44 public:
46  enum Type {
47  Error = 0,
48  Normal,
49  Chat,
50  GroupChat,
51  Headline
52  };
53 
60  enum State {
61  None = 0,
64  Gone,
66  Paused
67  };
68 
74  enum Marker {
75  NoMarker = 0,
76  Received,
77  Displayed,
78  Acknowledged
79  };
80 
86  enum Hint {
87  NoPermanentStore = 1 << 0,
88  NoStore = 1 << 1,
89  NoCopy = 1 << 2,
90  Store = 1 << 3
91  };
92 
103  OTR,
105  OX,
106  OMEMO
107  };
108 
109  QXmppMessage(const QString &from = QString(), const QString &to = QString(),
110  const QString &body = QString(), const QString &thread = QString());
111 
112  QXmppMessage(const QXmppMessage &other);
113  ~QXmppMessage() override;
114 
115  QXmppMessage &operator=(const QXmppMessage &other);
116 
117  bool isXmppStanza() const override;
118 
119  QString body() const;
120  void setBody(const QString &);
121 
122  QString subject() const;
123  void setSubject(const QString &);
124 
125  QString thread() const;
126  void setThread(const QString &);
127 
128  QString parentThread() const;
129  void setParentThread(const QString &);
130 
131  QXmppMessage::Type type() const;
132  void setType(QXmppMessage::Type);
133 
134  // XEP-0066: Out of Band Data
135  QString outOfBandUrl() const;
136  void setOutOfBandUrl(const QString &);
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 
186  // XEP-0308: Last Message Correction
187  QString replaceId() const;
188  void setReplaceId(const QString &);
189 
190  // XEP-0333: Chat State Markers
191  bool isMarkable() const;
192  void setMarkable(const bool);
193 
194  QString markedId() const;
195  void setMarkerId(const QString &);
196 
197  QString markedThread() const;
198  void setMarkedThread(const QString &);
199 
200  Marker marker() const;
201  void setMarker(const Marker);
202 
203  // XEP-0334: Message Processing Hints
204  bool hasHint(const Hint hint) const;
205  void addHint(const Hint hint);
206  void removeHint(const Hint hint);
207  void removeAllHints();
208 
209  // XEP-0359: Unique and Stable Stanza IDs
210  QString stanzaId() const;
211  void setStanzaId(const QString &id);
212 
213  QString stanzaIdBy() const;
214  void setStanzaIdBy(const QString &id);
215 
216  QString originId() const;
217  void setOriginId(const QString &id);
218 
219  // XEP-0367: Message Attaching
220  QString attachId() const;
221  void setAttachId(const QString &);
222 
223  // XEP-0369: Mediated Information eXchange (MIX)
224  QString mixUserJid() const;
225  void setMixUserJid(const QString &);
226 
227  QString mixUserNick() const;
228  void setMixUserNick(const QString &);
229 
230  // XEP-0380: Explicit Message Encryption
231  EncryptionMethod encryptionMethod() const;
232  void setEncryptionMethod(EncryptionMethod);
233  QString encryptionMethodNs() const;
234  void setEncryptionMethodNs(const QString &);
235 
236  QString encryptionName() const;
237  void setEncryptionName(const QString &);
238 
239  // XEP-0382: Spoiler messages
240  bool isSpoiler() const;
241  void setIsSpoiler(bool);
242 
243  QString spoilerHint() const;
244  void setSpoilerHint(const QString &);
245 
246  // XEP-0428: Fallback Indication
247  bool isFallback() const;
248  void setIsFallback(bool isFallback);
249 
251  void parse(const QDomElement &element) override;
252  void toXml(QXmlStreamWriter *writer) const override;
254 
255 private:
256  void parseExtension(const QDomElement &element, QXmppElementList &unknownExtensions);
257  void parseXElement(const QDomElement &element, QXmppElementList &unknownElements);
258 
259  QSharedDataPointer<QXmppMessagePrivate> d;
260 };
261 
262 #endif // QXMPPMESSAGE_H
QXmppStanza::operator=
QXmppStanza & operator=(const QXmppStanza &other)
Assigns other to this stanza.
Definition: QXmppStanza.cpp:583
QXmppMessage::Active
@ Active
User is actively participating in the chat session.
Definition: QXmppMessage.h:62
QXmppStanza::Error
The Error class represents a stanza error.
Definition: QXmppStanza.h:105
QXmppStanza::isXmppStanza
virtual bool isXmppStanza() const
Definition: QXmppStanza.cpp:710
QXmppMessage::EncryptionMethod
EncryptionMethod
Definition: QXmppMessage.h:100
QXmppMessage::OX
@ OX
XEP-0373: OpenPGP for XMPP
Definition: QXmppMessage.h:105
QXmppMessage::UnknownEncryption
@ UnknownEncryption
Unknown encryption.
Definition: QXmppMessage.h:102
QXmppStanza
The QXmppStanza class is the base class for all XMPP stanzas.
Definition: QXmppStanza.h:99
QXmppBitsOfBinaryDataList
Definition: QXmppBitsOfBinaryDataList.h:39
QXmppMessage::OTR
@ OTR
XEP-0364: Current Off-the-Record Messaging Usage
Definition: QXmppMessage.h:103
QXmppMessage::Inactive
@ Inactive
User has not been actively participating in the chat session.
Definition: QXmppMessage.h:63
QXmppMessage::Type
Type
This enum describes a message type.
Definition: QXmppMessage.h:46
QXmppMessage::Gone
@ Gone
User has effectively ended their participation in the chat session.
Definition: QXmppMessage.h:64
QXmppMessage::NoEncryption
@ NoEncryption
No encryption.
Definition: QXmppMessage.h:101
QXmppMessage::LegacyOpenPGP
@ LegacyOpenPGP
XEP-0027: Current Jabber OpenPGP Usage
Definition: QXmppMessage.h:104
QXmppMessage::State
State
Definition: QXmppMessage.h:60
QXmppMessage::Marker
Marker
Definition: QXmppMessage.h:74
QXmppMessage
The QXmppMessage class represents an XMPP message.
Definition: QXmppMessage.h:42
QXmppMessage::Composing
@ Composing
User is composing a message.
Definition: QXmppMessage.h:65
QXmppMessage::Hint
Hint
Definition: QXmppMessage.h:86