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