QXmpp Version: 1.12.0
Loading...
Searching...
No Matches
QXmppStanza.h
1// SPDX-FileCopyrightText: 2009 Manjeet Dahiya <manjeetdahiya@gmail.com>
2// SPDX-FileCopyrightText: 2010 Jeremy Lainé <jeremy.laine@m4x.org>
3// SPDX-FileCopyrightText: 2015 Georg Rudoy <0xd34df00d@gmail.com>
4// SPDX-FileCopyrightText: 2019 Linus Jahn <lnj@kaidan.im>
5// SPDX-FileCopyrightText: 2022 Melvin Keskin <melvo@olomono.de>
6//
7// SPDX-License-Identifier: LGPL-2.1-or-later
8
9#ifndef QXMPPSTANZA_H
10#define QXMPPSTANZA_H
11
12#include <optional>
13
14#include <QByteArray>
15#include <QSharedData>
16
17// forward declarations of QXmlStream* classes will not work on Mac, we need to
18// include the whole header.
19// See http://lists.trolltech.com/qt-interest/2008-07/thread00798-0.html
20// for an explanation.
21#include "QXmppConstants_p.h"
22#include "QXmppElement.h"
23#include "QXmppNonza.h"
24
25#include <QXmlStreamWriter>
26
28class QXmppExtendedAddressPrivate;
29
39class QXMPP_EXPORT QXmppExtendedAddress
40{
41public:
46
49
50 QString description() const;
51 void setDescription(const QString &description);
52
53 QString jid() const;
54 void setJid(const QString &jid);
55
56 QString type() const;
57 void setType(const QString &type);
58
59 bool isDelivered() const;
60 void setDelivered(bool);
61
62 bool isValid() const;
63
65 static constexpr std::tuple XmlTag = { u"address", QXmpp::Private::ns_extended_addressing };
66 void parse(const QDomElement &element);
67 void toXml(QXmlStreamWriter *writer) const;
69
70private:
71 QSharedDataPointer<QXmppExtendedAddressPrivate> d;
72};
73
74class QXmppStanzaPrivate;
75class QXmppStanzaErrorPrivate;
76
83
89class QXMPP_EXPORT QXmppStanza : public QXmppNonza
90{
91public:
95 class QXMPP_EXPORT Error
96 {
97 public:
102 enum Type {
103 NoType = -1,
108 Wait
109 };
110
142
143 Error();
144 Error(const Error &);
146 Error(Type type, Condition cond, const QString &text = QString());
147 Error(const QString &type, const QString &cond, const QString &text = QString());
149 Error(QSharedDataPointer<QXmppStanzaErrorPrivate> d);
152
155
156 int code() const;
157 void setCode(int code);
158
159 QString text() const;
160 void setText(const QString &text);
161
162 Condition condition() const;
163 void setCondition(Condition cond);
164
165 Type type() const;
166 void setType(Type type);
167
168 QString by() const;
169 void setBy(const QString &by);
170
171 QString redirectionUri() const;
172 void setRedirectionUri(const QString &redirectionUri);
173
174 // XEP-0363: HTTP File Upload
175 bool fileTooLarge() const;
176 void setFileTooLarge(bool);
177
178 qint64 maxFileSize() const;
179 void setMaxFileSize(qint64);
180
181 QDateTime retryDate() const;
182 void setRetryDate(const QDateTime &);
183
185 void parse(const QDomElement &element);
186 void toXml(QXmlStreamWriter *writer) const;
188
189 private:
190 friend class QXmppStanza;
191
192 QSharedDataPointer<QXmppStanzaErrorPrivate> d;
193 };
194
195 QXmppStanza(const QString &from = QString(), const QString &to = QString());
198 ~QXmppStanza() override;
199
202
203 QString to() const;
204 void setTo(const QString &);
205
206 QString from() const;
207 void setFrom(const QString &);
208
209 QString id() const;
210 void setId(const QString &);
211
212 QString lang() const;
213 void setLang(const QString &);
214
215 QXmppStanza::Error error() const;
216 std::optional<Error> errorOptional() const;
217 void setError(const QXmppStanza::Error &error);
218 void setError(const std::optional<Error> &error);
219
220 QXmppElementList extensions() const;
221 void setExtensions(const QXmppElementList &elements);
222
223 QList<QXmppExtendedAddress> extendedAddresses() const;
224 void setExtendedAddresses(const QList<QXmppExtendedAddress> &extendedAddresses);
225
226 std::optional<QXmppE2eeMetadata> e2eeMetadata() const;
227 void setE2eeMetadata(const std::optional<QXmppE2eeMetadata> &e2eeMetadata);
228
230 void parse(const QDomElement &element) override;
231
232protected:
233 void extensionsToXml(QXmlStreamWriter *writer, QXmpp::SceMode = QXmpp::SceAll) const;
234 void generateAndSetNextId();
236
237private:
238 QSharedDataPointer<QXmppStanzaPrivate> d;
239 friend class TestClient;
240};
241
242Q_DECLARE_METATYPE(QXmppStanza::Error::Type);
243Q_DECLARE_METATYPE(QXmppStanza::Error::Condition);
244
245#endif // QXMPPSTANZA_H
The QXmppE2eeMetadata class contains data used for end-to-end encryption purposes.
Definition QXmppE2eeMetadata.h:16
Represents an extended address as defined by XEP-0033: Extended Stanza Addressing.
Definition QXmppStanza.h:40
QXmppExtendedAddress(const QXmppExtendedAddress &)
Default copy-constructur.
QXmppExtendedAddress(QXmppExtendedAddress &&)
Default move-constructur.
QXmppExtendedAddress & operator=(const QXmppExtendedAddress &)
Default assignment operator.
QXmppExtendedAddress & operator=(QXmppExtendedAddress &&)
Default assignment operator.
Definition QXmppNonza.h:14
The Error class represents a stanza error.
Definition QXmppStanza.h:96
Error & operator=(Error &&)
Move operator.
~Error()
Default destructor.
Error(Error &&)
Move constructor.
Type
Definition QXmppStanza.h:102
@ Auth
The request needs to be resent after authentication.
Definition QXmppStanza.h:107
@ Modify
The request needs to be changed and resent.
Definition QXmppStanza.h:106
@ Cancel
The error is not temporary.
Definition QXmppStanza.h:104
@ Continue
The error was only a warning.
Definition QXmppStanza.h:105
Condition
A detailed condition of the error.
Definition QXmppStanza.h:112
@ ItemNotFound
The requested item could not be found.
Definition QXmppStanza.h:120
@ ResourceConstraint
The recipient lacks system resources to perform the request.
Definition QXmppStanza.h:135
@ UndefinedCondition
An undefined condition was hit.
Definition QXmppStanza.h:138
@ Forbidden
The requesting entity does not posses the necessary privileges to perform the request.
Definition QXmppStanza.h:117
@ FeatureNotImplemented
The feature is not implemented.
Definition QXmppStanza.h:116
@ RegistrationRequired
The requesting entity needs to register first.
Definition QXmppStanza.h:132
@ NotAcceptable
The request does not meet the defined critera.
Definition QXmppStanza.h:122
@ Redirect
The requested resource is available elsewhere. This is used in combination with a redirection URI.
Definition QXmppStanza.h:131
@ BadRequest
The request does not contain a valid schema.
Definition QXmppStanza.h:114
@ NotAuthorized
The request should be resent after authentication.
Definition QXmppStanza.h:124
@ Conflict
The request conflicts with another.
Definition QXmppStanza.h:115
@ UnexpectedRequest
The request was unexpected.
Definition QXmppStanza.h:139
@ InternalServerError
The server has expierienced an internal error and can not process the request.
Definition QXmppStanza.h:119
@ Gone
The user or server can not be contacted at the address. This is used in combination with a redirectio...
Definition QXmppStanza.h:118
@ SubscriptionRequired
The requester needs to subscribe first.
Definition QXmppStanza.h:137
@ RemoteServerTimeout
The connection to the server could not be established or timed out.
Definition QXmppStanza.h:134
@ RemoteServerNotFound
The remote server could not be found.
Definition QXmppStanza.h:133
@ JidMalformed
The given JID is not valid.
Definition QXmppStanza.h:121
@ ServiceUnavailable
The service is currently not available.
Definition QXmppStanza.h:136
@ NotAllowed
No entity is allowed to perform the request.
Definition QXmppStanza.h:123
@ Q_DECL_ENUMERATOR_DEPRECATED_X
Definition QXmppStanza.h:128
Error & operator=(const Error &)
Copy operator.
Error(const Error &)
Copy constructor.
The QXmppStanza class is the base class for all XMPP stanzas.
Definition QXmppStanza.h:90
~QXmppStanza() override
Destroys a QXmppStanza.
QXmppStanza(QXmppStanza &&)
Move constructor.
QXmppStanza & operator=(const QXmppStanza &other)
Assigns other to this stanza.
QXmppStanza & operator=(QXmppStanza &&)
Move-assignment operator.
QXmppStanza(const QXmppStanza &other)
Constructs a copy of other.
SceMode
Definition QXmppGlobal.h:146
@ SceAll
Processes all known elements.
Definition QXmppGlobal.h:147