QXmppStanza.h
/*
* Copyright (C) 2008-2021 The QXmpp developers
*
* Authors:
* Manjeet Dahiya
* Jeremy Lainé
* Georg Rudoy
*
* Source:
* https://github.com/qxmpp-project/qxmpp
*
* This file is a part of QXmpp library.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
*/
#ifndef QXMPPSTANZA_H
#define QXMPPSTANZA_H
#include <QByteArray>
#include <QSharedData>
#include <QString>
// 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 <QXmlStreamWriter>
class QXmppExtendedAddressPrivate;
class QXMPP_EXPORT QXmppExtendedAddress
{
public:
QXmppExtendedAddress();
QXmppExtendedAddress(const QXmppExtendedAddress &);
~QXmppExtendedAddress();
QXmppExtendedAddress &operator=(const 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:
class QXMPP_EXPORT Error
{
public:
enum Type {
Cancel,
Continue,
Modify,
Auth,
Wait
};
enum Condition {
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(Type type, Condition cond, const QString &text = QString());
Error(const QString &type, const QString &cond, const QString &text = QString());
~Error();
Error &operator=(const Error &);
int code() const;
void setCode(int code);
QString text() const;
void setText(const QString &text);
Condition condition() const;
void setCondition(Condition cond);
void setType(Type type);
Type type() const;
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:
QSharedDataPointer<QXmppStanzaErrorPrivate> d;
};
QXmppStanza(const QString &from = QString(), const QString &to = QString());
QXmppStanza(const QXmppStanza &other);
virtual ~QXmppStanza();
QXmppStanza &operator=(const QXmppStanza &other);
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;
void setError(const QXmppStanza::Error &error);
QXmppElementList extensions() const;
void setExtensions(const QXmppElementList &elements);
QList<QXmppExtendedAddress> extendedAddresses() const;
void setExtendedAddresses(const QList<QXmppExtendedAddress> &extendedAddresses);
virtual bool isXmppStanza() const;
virtual void parse(const QDomElement &element);
virtual void toXml(QXmlStreamWriter *writer) const = 0;
protected:
void extensionsToXml(QXmlStreamWriter *writer) const;
void generateAndSetNextId();
private:
QSharedDataPointer<QXmppStanzaPrivate> d;
static uint s_uniqeIdNo;
};
Q_DECLARE_METATYPE(QXmppStanza::Error::Type);
Q_DECLARE_METATYPE(QXmppStanza::Error::Condition);
#endif // QXMPPSTANZA_H
QXmppExtendedAddress
Represents an extended address as defined by XEP-0033: Extended Stanza Addressing.
Definition: QXmppStanza.h:53
QXmppExtendedAddress::QXmppExtendedAddress
QXmppExtendedAddress(const QXmppExtendedAddress &)
QXmppStanza::Error
The Error class represents a stanza error.
Definition: QXmppStanza.h:106
QXmppStanza::Error::~Error
~Error()
Default destructor.
QXmppStanza::Error::Type
Type
Definition: QXmppStanza.h:112
QXmppStanza::Error::Auth
@ Auth
The request needs to be resent after authentication.
Definition: QXmppStanza.h:116
QXmppStanza::Error::Modify
@ Modify
The request needs to be changed and resent.
Definition: QXmppStanza.h:115
QXmppStanza::Error::Cancel
@ Cancel
The error is not temporary.
Definition: QXmppStanza.h:113
QXmppStanza::Error::Continue
@ Continue
The error was only a warning.
Definition: QXmppStanza.h:114
QXmppStanza::Error::Condition
Condition
A detailed condition of the error.
Definition: QXmppStanza.h:121
QXmppStanza::Error::ItemNotFound
@ ItemNotFound
The requested item could not be found.
Definition: QXmppStanza.h:128
QXmppStanza::Error::ResourceConstraint
@ ResourceConstraint
The recipient lacks system resources to perform the request.
Definition: QXmppStanza.h:143
QXmppStanza::Error::UndefinedCondition
@ UndefinedCondition
An undefined condition was hit.
Definition: QXmppStanza.h:146
QXmppStanza::Error::Forbidden
@ Forbidden
The requesting entity does not posses the necessary privileges to perform the request.
Definition: QXmppStanza.h:125
QXmppStanza::Error::FeatureNotImplemented
@ FeatureNotImplemented
The feature is not implemented.
Definition: QXmppStanza.h:124
QXmppStanza::Error::RegistrationRequired
@ RegistrationRequired
The requesting entity needs to register first.
Definition: QXmppStanza.h:140
QXmppStanza::Error::NotAcceptable
@ NotAcceptable
The request does not meet the defined critera.
Definition: QXmppStanza.h:130
QXmppStanza::Error::Redirect
@ Redirect
The requested resource is available elsewhere. This is used in combination with a redirection URI.
Definition: QXmppStanza.h:139
QXmppStanza::Error::BadRequest
@ BadRequest
The request does not contain a valid schema.
Definition: QXmppStanza.h:122
QXmppStanza::Error::NotAuthorized
@ NotAuthorized
The request should be resent after authentication.
Definition: QXmppStanza.h:132
QXmppStanza::Error::Conflict
@ Conflict
The request conflicts with another.
Definition: QXmppStanza.h:123
QXmppStanza::Error::UnexpectedRequest
@ UnexpectedRequest
The request was unexpected.
Definition: QXmppStanza.h:147
QXmppStanza::Error::InternalServerError
@ InternalServerError
The server has expierienced an internal error and can not process the request.
Definition: QXmppStanza.h:127
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:126
QXmppStanza::Error::SubscriptionRequired
@ SubscriptionRequired
The requester needs to subscribe first.
Definition: QXmppStanza.h:145
QXmppStanza::Error::RemoteServerTimeout
@ RemoteServerTimeout
The connection to the server could not be established or timed out.
Definition: QXmppStanza.h:142
QXmppStanza::Error::RemoteServerNotFound
@ RemoteServerNotFound
The remote server could not be found.
Definition: QXmppStanza.h:141
QXmppStanza::Error::JidMalformed
@ JidMalformed
The given JID is not valid.
Definition: QXmppStanza.h:129
QXmppStanza::Error::ServiceUnavailable
@ ServiceUnavailable
The service is currently not available.
Definition: QXmppStanza.h:144
QXmppStanza::Error::NotAllowed
@ NotAllowed
No entity is allowed to perform the request.
Definition: QXmppStanza.h:131
QXmppStanza::Error::Q_DECL_ENUMERATOR_DEPRECATED_X
@ Q_DECL_ENUMERATOR_DEPRECATED_X
Definition: QXmppStanza.h:136
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:100