diff options
| author | Linus Jahn <lnj@kaidan.im> | 2020-07-06 00:25:36 +0200 |
|---|---|---|
| committer | Linus Jahn <lnj@kaidan.im> | 2021-08-22 16:09:02 +0200 |
| commit | 086f366d800bd93563742426533848dc24aa6f30 (patch) | |
| tree | 46aed3ee693d4d3486d376ce63194e5fa9bf8bd5 /src/base/QXmppPubSubSubscription.h | |
| parent | b53a3e4ac270cdea8d69529f06b844d917c345c1 (diff) | |
| download | qxmpp-086f366d800bd93563742426533848dc24aa6f30.tar.gz | |
Add QXmppPubSubSubscription
Diffstat (limited to 'src/base/QXmppPubSubSubscription.h')
| -rw-r--r-- | src/base/QXmppPubSubSubscription.h | 121 |
1 files changed, 121 insertions, 0 deletions
diff --git a/src/base/QXmppPubSubSubscription.h b/src/base/QXmppPubSubSubscription.h new file mode 100644 index 00000000..0a0a010d --- /dev/null +++ b/src/base/QXmppPubSubSubscription.h @@ -0,0 +1,121 @@ +/* + * Copyright (C) 2008-2021 The QXmpp developers + * + * Author: + * Linus Jahn + * + * 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 QXMPPPUBSUBSUBSCRIPTION_H +#define QXMPPPUBSUBSUBSCRIPTION_H + +#include "QXmppGlobal.h" + +#include <QDateTime> +#include <QMetaType> +#include <QSharedDataPointer> + +class QXmppPubSubSubscriptionPrivate; +class QXmlStreamWriter; +class QDomElement; + +class QXMPP_EXPORT QXmppPubSubSubscription +{ +public: + /// + /// The State enum describes the state of a subscription. + /// + enum State : uint8_t { + /// No state information is included. + Invalid, + /// There is no subscription with the node. + None, + /// A subscription is pending. + Pending, + /// The user is subscribed to the node. + Subscribed, + /// The subscription requires configuration before it becomes active. + Unconfigured, + }; + static QString stateToString(State); + static State stateFromString(const QString &); + + /// + /// The SubscribeOptionsSupport enum describes whether the availability of a + /// subscription configuration. This is also known as + /// <subscribe-options/>. + /// + enum ConfigurationSupport : uint8_t { + /// A subscription configuration is not advertised. + Unavailable, + /// Configuration of the subscription is possible, but not required. + Available, + /// Configuration of the subscription is required. No event + /// notifications are going to be sent until the subscription has been + /// configured. + Required, + }; + + QXmppPubSubSubscription(const QString &jid = {}, + const QString &node = {}, + const QString &subId = {}, + State state = Invalid, + ConfigurationSupport configurationSupport = Unavailable, + const QDateTime &expiry = {}); + QXmppPubSubSubscription(const QXmppPubSubSubscription &); + ~QXmppPubSubSubscription(); + + QXmppPubSubSubscription &operator=(const QXmppPubSubSubscription &); + + QString jid() const; + void setJid(const QString &jid); + + QString node() const; + void setNode(const QString &node); + + QString subId() const; + void setSubId(const QString &subId); + + QDateTime expiry() const; + void setExpiry(const QDateTime &expiry); + + State state() const; + void setState(State state); + + ConfigurationSupport configurationSupport() const; + void setConfigurationSupport(ConfigurationSupport support); + bool isConfigurationSupported() const; + bool isConfigurationRequired() const; + + static bool isSubscription(const QDomElement &); + + /// \cond + void parse(const QDomElement &); + void toXml(QXmlStreamWriter *writer) const; + /// \endcond + +private: + QSharedDataPointer<QXmppPubSubSubscriptionPrivate> d; +}; + +Q_DECLARE_TYPEINFO(QXmppPubSubSubscription, Q_MOVABLE_TYPE); +Q_DECLARE_METATYPE(QXmppPubSubSubscription) +Q_DECLARE_METATYPE(QXmppPubSubSubscription::State) +Q_DECLARE_METATYPE(QXmppPubSubSubscription::ConfigurationSupport) + +#endif // QXMPPPUBSUBSUBSCRIPTION_H |
