Loading...
Searching...
No Matches
QXmppStanza.h
// SPDX-FileCopyrightText: 2009 Manjeet Dahiya <manjeetdahiya@gmail.com>
// SPDX-FileCopyrightText: 2010 Jeremy Lainé <jeremy.laine@m4x.org>
// SPDX-FileCopyrightText: 2015 Georg Rudoy <0xd34df00d@gmail.com>
// SPDX-FileCopyrightText: 2019 Linus Jahn <lnj@kaidan.im>
// SPDX-FileCopyrightText: 2022 Melvin Keskin <melvo@olomono.de>
//
// SPDX-License-Identifier: LGPL-2.1-or-later
#ifndef QXMPPSTANZA_H
#define QXMPPSTANZA_H
#include <optional>
#include <QByteArray>
#include <QSharedData>
// forward declarations of QXmlStream* classes will not work on Mac, we need to
// include the whole header.
// See http://lists.trolltech.com/qt-interest/2008-07/thread00798-0.html
// for an explanation.
#include "QXmppElement.h"
#include "QXmppNonza.h"
#include <QXmlStreamWriter>
class QXmppE2eeMetadata;
class QXmppExtendedAddressPrivate;
class QXMPP_EXPORT QXmppExtendedAddress
{
public:
QXmppExtendedAddress();
QXmppExtendedAddress(const QXmppExtendedAddress &);
QXmppExtendedAddress(QXmppExtendedAddress &&);
~QXmppExtendedAddress();
QXmppExtendedAddress &operator=(const QXmppExtendedAddress &);
QXmppExtendedAddress &operator=(QXmppExtendedAddress &&);
QString description() const;
void setDescription(const QString &description);
QString jid() const;
void setJid(const QString &jid);
QString type() const;
void setType(const QString &type);
bool isDelivered() const;
void setDelivered(bool);
bool isValid() const;
void parse(const QDomElement &element);
void toXml(QXmlStreamWriter *writer) const;
private:
QSharedDataPointer<QXmppExtendedAddressPrivate> d;
};
class QXmppStanzaPrivate;
class QXmppStanzaErrorPrivate;
class QXMPP_EXPORT QXmppStanza : public QXmppNonza
{
public:
class QXMPP_EXPORT Error
{
public:
enum Type {
NoType = -1,
Cancel,
Continue,
Modify,
Auth,
Wait
};
enum Condition {
NoCondition = -1,
BadRequest,
Conflict,
FeatureNotImplemented,
Forbidden,
Gone,
InternalServerError,
ItemNotFound,
JidMalformed,
NotAcceptable,
NotAllowed,
NotAuthorized,
#if QXMPP_DEPRECATED_SINCE(1, 3)
PaymentRequired Q_DECL_ENUMERATOR_DEPRECATED_X("The <payment-required/> error was removed in RFC6120"),
#endif
RecipientUnavailable = 12,
Redirect,
RegistrationRequired,
RemoteServerNotFound,
RemoteServerTimeout,
ResourceConstraint,
ServiceUnavailable,
SubscriptionRequired,
UndefinedCondition,
UnexpectedRequest,
PolicyViolation
};
Error();
Error(const Error &);
Error(Error &&);
Error(Type type, Condition cond, const QString &text = QString());
Error(const QString &type, const QString &cond, const QString &text = QString());
Error(QSharedDataPointer<QXmppStanzaErrorPrivate> d);
~Error();
Error &operator=(const Error &);
Error &operator=(Error &&);
int code() const;
void setCode(int code);
QString text() const;
void setText(const QString &text);
Condition condition() const;
void setCondition(Condition cond);
Type type() const;
void setType(Type type);
QString by() const;
void setBy(const QString &by);
QString redirectionUri() const;
void setRedirectionUri(const QString &redirectionUri);
// XEP-0363: HTTP File Upload
bool fileTooLarge() const;
void setFileTooLarge(bool);
qint64 maxFileSize() const;
void setMaxFileSize(qint64);
QDateTime retryDate() const;
void setRetryDate(const QDateTime &);
void parse(const QDomElement &element);
void toXml(QXmlStreamWriter *writer) const;
private:
friend class QXmppStanza;
QSharedDataPointer<QXmppStanzaErrorPrivate> d;
};
QXmppStanza(const QString &from = QString(), const QString &to = QString());
QXmppStanza(const QXmppStanza &other);
QXmppStanza(QXmppStanza &&);
virtual ~QXmppStanza();
QXmppStanza &operator=(const QXmppStanza &other);
QXmppStanza &operator=(QXmppStanza &&);
QString to() const;
void setTo(const QString &);
QString from() const;
void setFrom(const QString &);
QString id() const;
void setId(const QString &);
QString lang() const;
void setLang(const QString &);
QXmppStanza::Error error() const;
std::optional<Error> errorOptional() const;
void setError(const QXmppStanza::Error &error);
void setError(const std::optional<Error> &error);
QXmppElementList extensions() const;
void setExtensions(const QXmppElementList &elements);
QList<QXmppExtendedAddress> extendedAddresses() const;
void setExtendedAddresses(const QList<QXmppExtendedAddress> &extendedAddresses);
std::optional<QXmppE2eeMetadata> e2eeMetadata() const;
void setE2eeMetadata(const std::optional<QXmppE2eeMetadata> &e2eeMetadata);
void parse(const QDomElement &element) override;
protected:
void extensionsToXml(QXmlStreamWriter *writer, QXmpp::SceMode = QXmpp::SceAll) const;
void generateAndSetNextId();
private:
QSharedDataPointer<QXmppStanzaPrivate> d;
static uint s_uniqeIdNo;
friend class TestClient;
};
Q_DECLARE_METATYPE(QXmppStanza::Error::Type);
Q_DECLARE_METATYPE(QXmppStanza::Error::Condition);
#endif // QXMPPSTANZA_H
QXmppE2eeMetadata
The QXmppE2eeMetadata class contains data used for end-to-end encryption purposes.
Definition QXmppE2eeMetadata.h:16
QXmppExtendedAddress
Represents an extended address as defined by XEP-0033: Extended Stanza Addressing.
Definition QXmppStanza.h:39
QXmppExtendedAddress::QXmppExtendedAddress
QXmppExtendedAddress(const QXmppExtendedAddress &)
Default copy-constructur.
QXmppExtendedAddress::QXmppExtendedAddress
QXmppExtendedAddress(QXmppExtendedAddress &&)
Default move-constructur.
QXmppExtendedAddress::operator=
QXmppExtendedAddress & operator=(const QXmppExtendedAddress &)
Default assignment operator.
QXmppExtendedAddress::operator=
QXmppExtendedAddress & operator=(QXmppExtendedAddress &&)
Default assignment operator.
QXmppNonza
Definition QXmppNonza.h:14
QXmppStanza::Error
The Error class represents a stanza error.
Definition QXmppStanza.h:94
QXmppStanza::Error::operator=
Error & operator=(Error &&)
Move operator.
QXmppStanza::Error::~Error
~Error()
Default destructor.
QXmppStanza::Error::Error
Error(Error &&)
Move constructor.
QXmppStanza::Error::Type
Type
Definition QXmppStanza.h:100
QXmppStanza::Error::Auth
@ Auth
The request needs to be resent after authentication.
Definition QXmppStanza.h:105
QXmppStanza::Error::Modify
@ Modify
The request needs to be changed and resent.
Definition QXmppStanza.h:104
QXmppStanza::Error::Cancel
@ Cancel
The error is not temporary.
Definition QXmppStanza.h:102
QXmppStanza::Error::Continue
@ Continue
The error was only a warning.
Definition QXmppStanza.h:103
QXmppStanza::Error::Condition
Condition
A detailed condition of the error.
Definition QXmppStanza.h:110
QXmppStanza::Error::ItemNotFound
@ ItemNotFound
The requested item could not be found.
Definition QXmppStanza.h:118
QXmppStanza::Error::ResourceConstraint
@ ResourceConstraint
The recipient lacks system resources to perform the request.
Definition QXmppStanza.h:133
QXmppStanza::Error::UndefinedCondition
@ UndefinedCondition
An undefined condition was hit.
Definition QXmppStanza.h:136
QXmppStanza::Error::Forbidden
@ Forbidden
The requesting entity does not posses the necessary privileges to perform the request.
Definition QXmppStanza.h:115
QXmppStanza::Error::FeatureNotImplemented
@ FeatureNotImplemented
The feature is not implemented.
Definition QXmppStanza.h:114
QXmppStanza::Error::RegistrationRequired
@ RegistrationRequired
The requesting entity needs to register first.
Definition QXmppStanza.h:130
QXmppStanza::Error::NotAcceptable
@ NotAcceptable
The request does not meet the defined critera.
Definition QXmppStanza.h:120
QXmppStanza::Error::Redirect
@ Redirect
The requested resource is available elsewhere. This is used in combination with a redirection URI.
Definition QXmppStanza.h:129
QXmppStanza::Error::BadRequest
@ BadRequest
The request does not contain a valid schema.
Definition QXmppStanza.h:112
QXmppStanza::Error::NotAuthorized
@ NotAuthorized
The request should be resent after authentication.
Definition QXmppStanza.h:122
QXmppStanza::Error::Conflict
@ Conflict
The request conflicts with another.
Definition QXmppStanza.h:113
QXmppStanza::Error::UnexpectedRequest
@ UnexpectedRequest
The request was unexpected.
Definition QXmppStanza.h:137
QXmppStanza::Error::InternalServerError
@ InternalServerError
The server has expierienced an internal error and can not process the request.
Definition QXmppStanza.h:117
QXmppStanza::Error::Gone
@ Gone
The user or server can not be contacted at the address. This is used in combination with a redirectio...
Definition QXmppStanza.h:116
QXmppStanza::Error::SubscriptionRequired
@ SubscriptionRequired
The requester needs to subscribe first.
Definition QXmppStanza.h:135
QXmppStanza::Error::RemoteServerTimeout
@ RemoteServerTimeout
The connection to the server could not be established or timed out.
Definition QXmppStanza.h:132
QXmppStanza::Error::RemoteServerNotFound
@ RemoteServerNotFound
The remote server could not be found.
Definition QXmppStanza.h:131
QXmppStanza::Error::JidMalformed
@ JidMalformed
The given JID is not valid.
Definition QXmppStanza.h:119
QXmppStanza::Error::ServiceUnavailable
@ ServiceUnavailable
The service is currently not available.
Definition QXmppStanza.h:134
QXmppStanza::Error::NotAllowed
@ NotAllowed
No entity is allowed to perform the request.
Definition QXmppStanza.h:121
QXmppStanza::Error::Q_DECL_ENUMERATOR_DEPRECATED_X
@ Q_DECL_ENUMERATOR_DEPRECATED_X
Definition QXmppStanza.h:126
QXmppStanza::Error::operator=
Error & operator=(const Error &)
Copy operator.
QXmppStanza::Error::Error
Error(const Error &)
Copy constructor.
QXmppStanza
The QXmppStanza class is the base class for all XMPP stanzas.
Definition QXmppStanza.h:88
QXmppStanza::QXmppStanza
QXmppStanza(QXmppStanza &&)
Move constructor.
QXmppStanza::operator=
QXmppStanza & operator=(const QXmppStanza &other)
Assigns other to this stanza.
QXmppStanza::~QXmppStanza
virtual ~QXmppStanza()
Destroys a QXmppStanza.
QXmppStanza::operator=
QXmppStanza & operator=(QXmppStanza &&)
Move-assignment operator.
QXmppStanza::QXmppStanza
QXmppStanza(const QXmppStanza &other)
Constructs a copy of other.
QXmpp::SceMode
SceMode
Definition QXmppGlobal.h:136
QXmpp::SceAll
@ SceAll
Processes all known elements.
Definition QXmppGlobal.h:137