From 040b7d9a8c7625f93e93690e47dbabb71ff87fd7 Mon Sep 17 00:00:00 2001 From: Linus Jahn Date: Fri, 3 Sep 2021 18:17:40 +0200 Subject: Refactor packet sending: Add SendSuccess/SendError --- src/base/QXmppSendResult.h | 48 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/base/QXmppSendResult.h (limited to 'src/base/QXmppSendResult.h') diff --git a/src/base/QXmppSendResult.h b/src/base/QXmppSendResult.h new file mode 100644 index 00000000..15b84b05 --- /dev/null +++ b/src/base/QXmppSendResult.h @@ -0,0 +1,48 @@ +#ifndef QXMPPSENDRESULT_H +#define QXMPPSENDRESULT_H + +#include "QXmppGlobal.h" + +#include + +namespace QXmpp { + +/// +/// A struct containing a packet send error type and error message. +/// +/// \since QXmpp 1.5 +/// +struct SendError +{ + /// Describes the type of an error. + enum Type : uint8_t { + SocketWriteError, ///< The packet was written to the socket with no success (only happens when Stream Management is disabled). + Disconnected, ///< The packet couldn't be sent because the connection hasn't been (re)established. + EncryptionError, ///< The packet couldn't be sent because prior encryption failed. + }; + + /// Text describing the error. + QString text; + /// Type of the occured error. + Type type; +}; + +/// +/// A struct indicating success when sending packets +/// +/// \since QXmpp 1.5 +/// +struct SendSuccess +{ + /// Indicates whether the packet has been acknowledged by the other peer. + bool acknowledged = false; +}; + +/// +/// A variant containing either a SendSuccess object or a SendError. +/// +using SendResult = std::variant; + +} + +#endif // QXMPPSENDRESULT_H -- cgit v1.2.3