aboutsummaryrefslogtreecommitdiff
path: root/src/base/QXmppSendResult.h
blob: b4b4ce818455a5de0e617293785b5d11e95509e3 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// SPDX-FileCopyrightText: 2021 Linus Jahn <lnj@kaidan.im>
//
// SPDX-License-Identifier: LGPL-2.1-or-later

#ifndef QXMPPSENDRESULT_H
#define QXMPPSENDRESULT_H

#include "QXmppGlobal.h"

#include <variant>

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<SendSuccess, SendError>;

}  // namespace QXmpp

#endif  // QXMPPSENDRESULT_H