QXmpp  Version:1.2.0
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 
40 
41 class QXMPP_EXPORT QXmppMessage : public QXmppStanza
42 {
43 public:
45  enum Type {
46  Error = 0,
47  Normal,
48  Chat,
49  GroupChat,
50  Headline
51  };
52 
55  enum State {
56  None = 0,
59  Gone,
61  Paused
62  };
63 
65  enum Marker {
66  NoMarker = 0,
67  Received,
68  Displayed,
69  Acknowledged
70  };
71 
75  enum Hint {
76  NoPermanentStore = 1 << 0,
77  NoStore = 1 << 1,
78  NoCopy = 1 << 2,
79  Store = 1 << 3
80  };
81 
90  OTR,
92  OX,
93  OMEMO
94  };
95 
96  QXmppMessage(const QString &from = QString(), const QString &to = QString(),
97  const QString &body = QString(), const QString &thread = QString());
98 
99  QXmppMessage(const QXmppMessage &other);
100  ~QXmppMessage() override;
101 
102  QXmppMessage &operator=(const QXmppMessage &other);
103 
104  bool isXmppStanza() const override;
105 
106  QString body() const;
107  void setBody(const QString &);
108 
109  bool isAttentionRequested() const;
110  void setAttentionRequested(bool requested);
111 
112  bool isReceiptRequested() const;
113  void setReceiptRequested(bool requested);
114 
115  QString mucInvitationJid() const;
116  void setMucInvitationJid(const QString &jid);
117 
118  QString mucInvitationPassword() const;
119  void setMucInvitationPassword(const QString &password);
120 
121  QString mucInvitationReason() const;
122  void setMucInvitationReason(const QString &reason);
123 
124  QString receiptId() const;
125  void setReceiptId(const QString &id);
126 
127  QDateTime stamp() const;
128  void setStamp(const QDateTime &stamp);
129 
130  QXmppMessage::State state() const;
131  void setState(QXmppMessage::State);
132 
133  QString subject() const;
134  void setSubject(const QString &);
135 
136  QString thread() const;
137  void setThread(const QString &);
138 
139  QXmppMessage::Type type() const;
140  void setType(QXmppMessage::Type);
141 
142  QString xhtml() const;
143  void setXhtml(const QString &xhtml);
144 
145  // XEP-0333: Chat State Markers
146  bool isMarkable() const;
147  void setMarkable(const bool);
148 
149  QString markedId() const;
150  void setMarkerId(const QString &);
151 
152  QString markedThread() const;
153  void setMarkedThread(const QString &);
154 
155  Marker marker() const;
156  void setMarker(const Marker);
157 
158  // XEP-0231: Bits of Binary
159  QXmppBitsOfBinaryDataList bitsOfBinaryData() const;
160  QXmppBitsOfBinaryDataList &bitsOfBinaryData();
161  void setBitsOfBinaryData(const QXmppBitsOfBinaryDataList &bitsOfBinaryData);
162 
163  // XEP-0280: Message Carbons
164  bool isPrivate() const;
165  void setPrivate(const bool);
166 
167  // XEP-0066: Out of Band Data
168  QString outOfBandUrl() const;
169  void setOutOfBandUrl(const QString &);
170 
171  // XEP-0308: Last Message Correction
172  QString replaceId() const;
173  void setReplaceId(const QString &);
174 
175  // XEP-0334: Message Processing Hints
176  bool hasHint(const Hint hint) const;
177  void addHint(const Hint hint);
178  void removeHint(const Hint hint);
179  void removeAllHints();
180 
181  // XEP-0367: Message Attaching
182  QString attachId() const;
183  void setAttachId(const QString &);
184 
185  // XEP-0369: Mediated Information eXchange (MIX)
186  QString mixUserJid() const;
187  void setMixUserJid(const QString &);
188 
189  QString mixUserNick() const;
190  void setMixUserNick(const QString &);
191 
192  // XEP-0380: Explicit Message Encryption
193  EncryptionMethod encryptionMethod() const;
194  void setEncryptionMethod(EncryptionMethod);
195  QString encryptionMethodNs() const;
196  void setEncryptionMethodNs(const QString &);
197 
198  QString encryptionName() const;
199  void setEncryptionName(const QString &);
200 
201  // XEP-0382: Spoiler messages
202  bool isSpoiler() const;
203  void setIsSpoiler(bool);
204 
205  QString spoilerHint() const;
206  void setSpoilerHint(const QString &);
207 
209  void parse(const QDomElement &element) override;
210  void toXml(QXmlStreamWriter *writer) const override;
212 
213 private:
214  void parseExtension(const QDomElement &element, QXmppElementList &unknownElements);
215  void parseXElement(const QDomElement &element, QXmppElementList &unknownElements);
216 
217  QSharedDataPointer<QXmppMessagePrivate> d;
218 };
219 
220 #endif // QXMPPMESSAGE_H
QXmppStanza::operator=
QXmppStanza & operator=(const QXmppStanza &other)
Assigns other to this stanza.
Definition: QXmppStanza.cpp:505
QXmppMessage::Active
User is actively participating in the chat session.
Definition: QXmppMessage.h:57
QXmppStanza::Error
The Error class represents a stanza error.
Definition: QXmppStanza.h:102
QXmppStanza::isXmppStanza
virtual bool isXmppStanza() const
Definition: QXmppStanza.cpp:629
QXmppMessage::EncryptionMethod
EncryptionMethod
Definition: QXmppMessage.h:87
QXmppMessage::OX
XEP-0373: OpenPGP for XMPP.
Definition: QXmppMessage.h:92
QXmppMessage::UnknownEncryption
Unknown encryption.
Definition: QXmppMessage.h:89
QXmppStanza
The QXmppStanza class is the base class for all XMPP stanzas.
Definition: QXmppStanza.h:96
QXmppBitsOfBinaryDataList
Definition: QXmppBitsOfBinaryDataList.h:39
QXmppMessage::OTR
XEP-0364: Current Off-the-Record Messaging Usage.
Definition: QXmppMessage.h:90
QXmppMessage::Inactive
User has not been actively participating in the chat session.
Definition: QXmppMessage.h:58
QXmppMessage::Type
Type
This enum describes a message type.
Definition: QXmppMessage.h:45
QXmppMessage::Gone
User has effectively ended their participation in the chat session.
Definition: QXmppMessage.h:59
QXmppMessage::NoEncryption
No encryption.
Definition: QXmppMessage.h:88
QXmppMessage::LegacyOpenPGP
XEP-0027: Current Jabber OpenPGP Usage.
Definition: QXmppMessage.h:91
QXmppMessage::State
State
Definition: QXmppMessage.h:55
QXmppMessage::Marker
Marker
This enum describes a chat marker as defined by XEP-0333: Chat Markers.
Definition: QXmppMessage.h:65
QXmppMessage
The QXmppMessage class represents an XMPP message.
Definition: QXmppMessage.h:41
QXmppMessage::Composing
User is composing a message.
Definition: QXmppMessage.h:60
QXmppMessage::Hint
Hint
Definition: QXmppMessage.h:75