diff options
| author | Linus Jahn <lnj@kaidan.im> | 2022-03-12 22:58:06 +0100 |
|---|---|---|
| committer | Linus Jahn <lnj@kaidan.im> | 2022-03-12 23:28:53 +0100 |
| commit | 769911c613cbae55a3630a6056961582b834aea3 (patch) | |
| tree | 2911d1b0067d66edd0e5054176a680c8a2d7116e /src/base/QXmppStanza.cpp | |
| parent | f4ed48231bf1ea39555213b42fc9cdb762f5f600 (diff) | |
| download | qxmpp-769911c613cbae55a3630a6056961582b834aea3.tar.gz | |
Stanza::Error: Add optional overloads for Condition/Type
Currently Condition(-1)/Type(-1) is used for an unset error. This should
be deprecated and replaced by the new optional<Condition/Type>
functions.
Diffstat (limited to 'src/base/QXmppStanza.cpp')
| -rw-r--r-- | src/base/QXmppStanza.cpp | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/src/base/QXmppStanza.cpp b/src/base/QXmppStanza.cpp index 848693da..8dabb07a 100644 --- a/src/base/QXmppStanza.cpp +++ b/src/base/QXmppStanza.cpp @@ -1,6 +1,7 @@ // 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 @@ -388,12 +389,28 @@ void QXmppStanza::Error::setCode(int code) /// The conditions QXmppStanza::Error::Gone and QXmppStanza::Error::Redirect /// can be used in combination with redirectUri(). /// +/// \warning Due to compatibility this returns \c Condition(-1) when no +/// condition is set. When possible you should use conditionOpt(). +/// QXmppStanza::Error::Condition QXmppStanza::Error::condition() const { return d->condition.value_or(QXmppStanza::Error::Condition(-1)); } /// +/// Returns the error condition. +/// +/// The conditions QXmppStanza::Error::Gone and QXmppStanza::Error::Redirect +/// can be used in combination with redirectUri(). +/// +/// \since QXmpp 1.5 +/// +auto QXmppStanza::Error::conditionOpt() const -> std::optional<Condition> +{ + return d->condition; +} + +/// /// Sets the error condition. /// /// The conditions QXmppStanza::Error::Gone and QXmppStanza::Error::Redirect @@ -409,14 +426,40 @@ void QXmppStanza::Error::setCondition(QXmppStanza::Error::Condition cond) } /// +/// Sets the error condition. +/// +/// The conditions QXmppStanza::Error::Gone and QXmppStanza::Error::Redirect +/// can be used in combination with setRedirectUri(). +/// +/// \since QXmpp 1.5 +/// +void QXmppStanza::Error::setCondition(std::optional<Condition> cond) +{ + d->condition = cond; +} + +/// /// Returns the type of the error. /// +/// \warning Due to compatibility this returns \c Type(-1) when no type is set. +/// When possible you should use typeOpt(). +/// QXmppStanza::Error::Type QXmppStanza::Error::type() const { return d->type.value_or(QXmppStanza::Error::Type(-1)); } /// +/// Returns the type of the error. +/// +/// \since QXmpp 1.5 +/// +std::optional<QXmppStanza::Error::Type> QXmppStanza::Error::typeOpt() const +{ + return d->type; +} + +/// /// Returns the optional JID of the creator of the error. /// /// This is useful to ditinguish between errors generated by the local server @@ -455,6 +498,16 @@ void QXmppStanza::Error::setType(QXmppStanza::Error::Type type) } /// +/// Sets the type of the error. +/// +/// \since QXmpp 1.5 +/// +void QXmppStanza::Error::setType(std::optional<Type> type) +{ + d->type = type; +} + +/// /// Returns the optionally included redirection URI for the error conditions /// QXmppStanza::Error::Gone and QXmppStanza::Error::Redirect. /// |
