QXmpp Version: 1.4.0
QXmppStanza.h
1/*
2 * Copyright (C) 2008-2021 The QXmpp developers
3 *
4 * Authors:
5 * Manjeet Dahiya
6 * Jeremy Lainé
7 * Georg Rudoy
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 QXMPPSTANZA_H
27#define QXMPPSTANZA_H
28
29#include <QByteArray>
30#include <QSharedData>
31#include <QString>
32
33// forward declarations of QXmlStream* classes will not work on Mac, we need to
34// include the whole header.
35// See http://lists.trolltech.com/qt-interest/2008-07/thread00798-0.html
36// for an explanation.
37#include "QXmppElement.h"
38
39#include <QXmlStreamWriter>
40
41class QXmppExtendedAddressPrivate;
42
52class QXMPP_EXPORT QXmppExtendedAddress
53{
54public:
58
60
61 QString description() const;
62 void setDescription(const QString &description);
63
64 QString jid() const;
65 void setJid(const QString &jid);
66
67 QString type() const;
68 void setType(const QString &type);
69
70 bool isDelivered() const;
71 void setDelivered(bool);
72
73 bool isValid() const;
74
76 void parse(const QDomElement &element);
77 void toXml(QXmlStreamWriter *writer) const;
79
80private:
81 QSharedDataPointer<QXmppExtendedAddressPrivate> d;
82};
83
84class QXmppStanzaPrivate;
85class QXmppStanzaErrorPrivate;
86
93
99class QXMPP_EXPORT QXmppStanza
100{
101public:
105 class QXMPP_EXPORT Error
106 {
107 public:
112 enum Type {
117 Wait
118 };
119
133#if QXMPP_DEPRECATED_SINCE(1, 3)
136 PaymentRequired Q_DECL_ENUMERATOR_DEPRECATED_X("The <payment-required/> error was removed in RFC6120"),
137#endif
138 RecipientUnavailable = 12,
148 PolicyViolation
149 };
150
151 Error();
152 Error(const Error &);
153 Error(Type type, Condition cond, const QString &text = QString());
154 Error(const QString &type, const QString &cond, const QString &text = QString());
156
158
159 int code() const;
160 void setCode(int code);
161
162 QString text() const;
163 void setText(const QString &text);
164
165 Condition condition() const;
166 void setCondition(Condition cond);
167
168 void setType(Type type);
169 Type type() const;
170
171 QString by() const;
172 void setBy(const QString &by);
173
174 QString redirectionUri() const;
175 void setRedirectionUri(const QString &redirectionUri);
176
177 // XEP-0363: HTTP File Upload
178 bool fileTooLarge() const;
179 void setFileTooLarge(bool);
180
181 qint64 maxFileSize() const;
182 void setMaxFileSize(qint64);
183
184 QDateTime retryDate() const;
185 void setRetryDate(const QDateTime &);
186
188 void parse(const QDomElement &element);
189 void toXml(QXmlStreamWriter *writer) const;
191
192 private:
193 QSharedDataPointer<QXmppStanzaErrorPrivate> d;
194 };
195
196 QXmppStanza(const QString &from = QString(), const QString &to = QString());
197 QXmppStanza(const QXmppStanza &other);
198 virtual ~QXmppStanza();
199
200 QXmppStanza &operator=(const QXmppStanza &other);
201
202 QString to() const;
203 void setTo(const QString &);
204
205 QString from() const;
206 void setFrom(const QString &);
207
208 QString id() const;
209 void setId(const QString &);
210
211 QString lang() const;
212 void setLang(const QString &);
213
214 QXmppStanza::Error error() const;
215 void setError(const QXmppStanza::Error &error);
216
217 QXmppElementList extensions() const;
218 void setExtensions(const QXmppElementList &elements);
219
220 QList<QXmppExtendedAddress> extendedAddresses() const;
221 void setExtendedAddresses(const QList<QXmppExtendedAddress> &extendedAddresses);
222
223 virtual bool isXmppStanza() const;
224
226 virtual void parse(const QDomElement &element);
227 virtual void toXml(QXmlStreamWriter *writer) const = 0;
228
229protected:
230 void extensionsToXml(QXmlStreamWriter *writer) const;
231 void generateAndSetNextId();
233
234private:
235 QSharedDataPointer<QXmppStanzaPrivate> d;
236 static uint s_uniqeIdNo;
237};
238
239Q_DECLARE_METATYPE(QXmppStanza::Error::Type);
240Q_DECLARE_METATYPE(QXmppStanza::Error::Condition);
241
242#endif // QXMPPSTANZA_H
Represents an extended address as defined by XEP-0033: Extended Stanza Addressing.
Definition: QXmppStanza.h:53
QXmppExtendedAddress(const QXmppExtendedAddress &)
The Error class represents a stanza error.
Definition: QXmppStanza.h:106
~Error()
Default destructor.
Type
Definition: QXmppStanza.h:112
@ Auth
The request needs to be resent after authentication.
Definition: QXmppStanza.h:116
@ Modify
The request needs to be changed and resent.
Definition: QXmppStanza.h:115
@ Cancel
The error is not temporary.
Definition: QXmppStanza.h:113
@ Continue
The error was only a warning.
Definition: QXmppStanza.h:114
Condition
A detailed condition of the error.
Definition: QXmppStanza.h:121
@ ItemNotFound
The requested item could not be found.
Definition: QXmppStanza.h:128
@ ResourceConstraint
The recipient lacks system resources to perform the request.
Definition: QXmppStanza.h:143
@ UndefinedCondition
An undefined condition was hit.
Definition: QXmppStanza.h:146
@ Forbidden
The requesting entity does not posses the necessary privileges to perform the request.
Definition: QXmppStanza.h:125
@ FeatureNotImplemented
The feature is not implemented.
Definition: QXmppStanza.h:124
@ RegistrationRequired
The requesting entity needs to register first.
Definition: QXmppStanza.h:140
@ NotAcceptable
The request does not meet the defined critera.
Definition: QXmppStanza.h:130
@ Redirect
The requested resource is available elsewhere. This is used in combination with a redirection URI.
Definition: QXmppStanza.h:139
@ BadRequest
The request does not contain a valid schema.
Definition: QXmppStanza.h:122
@ NotAuthorized
The request should be resent after authentication.
Definition: QXmppStanza.h:132
@ Conflict
The request conflicts with another.
Definition: QXmppStanza.h:123
@ UnexpectedRequest
The request was unexpected.
Definition: QXmppStanza.h:147
@ InternalServerError
The server has expierienced an internal error and can not process the request.
Definition: QXmppStanza.h:127
@ Gone
The user or server can not be contacted at the address. This is used in combination with a redirectio...
Definition: QXmppStanza.h:126
@ SubscriptionRequired
The requester needs to subscribe first.
Definition: QXmppStanza.h:145
@ RemoteServerTimeout
The connection to the server could not be established or timed out.
Definition: QXmppStanza.h:142
@ RemoteServerNotFound
The remote server could not be found.
Definition: QXmppStanza.h:141
@ JidMalformed
The given JID is not valid.
Definition: QXmppStanza.h:129
@ ServiceUnavailable
The service is currently not available.
Definition: QXmppStanza.h:144
@ NotAllowed
No entity is allowed to perform the request.
Definition: QXmppStanza.h:131
@ Q_DECL_ENUMERATOR_DEPRECATED_X
Definition: QXmppStanza.h:136
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:100