QXmpp Version: 1.11.3
Loading...
Searching...
No Matches
StreamError.h
1// SPDX-FileCopyrightText: 2024 Linus Jahn <lnj@kaidan.im>
2//
3// SPDX-License-Identifier: LGPL-2.1-or-later
4
5#ifndef STREAMERROR_H
6#define STREAMERROR_H
7
8#include "QXmppError.h"
9#include "QXmppStreamError.h"
10
11#include "Enums.h"
12
13#include <variant>
14
15class QDomElement;
16class QXmlStreamWriter;
17namespace QXmpp::Private {
18class XmlWriter;
19}
20
21namespace QXmpp::Private {
22
23template<>
24struct Enums::Data<StreamError> {
25 using enum StreamError;
26 static constexpr auto Values = makeValues<StreamError>({
27 { BadFormat, u"bad-format" },
28 { BadNamespacePrefix, u"bad-namespace-prefix" },
29 { Conflict, u"conflict" },
30 { ConnectionTimeout, u"connection-timeout" },
31 { HostGone, u"host-gone" },
32 { HostUnknown, u"host-unknown" },
33 { ImproperAddressing, u"improper-addressing" },
34 { InternalServerError, u"internal-server-error" },
35 { InvalidFrom, u"invalid-from" },
36 { InvalidId, u"invalid-id" },
37 { InvalidNamespace, u"invalid-namespace" },
38 { InvalidXml, u"invalid-xml" },
39 { NotAuthorized, u"not-authorized" },
40 { NotWellFormed, u"not-well-formed" },
41 { PolicyViolation, u"policy-violation" },
42 { RemoteConnectionFailed, u"remote-connection-failed" },
43 { Reset, u"reset" },
44 { ResourceConstraint, u"resource-constraint" },
45 { RestrictedXml, u"restricted-xml" },
46 { SystemShutdown, u"system-shutdown" },
47 { UndefinedCondition, u"undefined-condition" },
48 { UnsupportedEncoding, u"unsupported-encoding" },
49 { UnsupportedFeature, u"unsupported-feature" },
50 { UnsupportedStanzaType, u"unsupported-stanza-type" },
51 { UnsupportedVersion, u"unsupported-version" },
52 });
53};
54
55// implemented in Stream.cpp
56struct StreamErrorElement {
57 struct SeeOtherHost {
58 QString host;
59 quint16 port;
60
61 bool operator==(const SeeOtherHost &o) const { return host == o.host && port == o.port; }
62 };
63
64 using Condition = std::variant<StreamError, SeeOtherHost>;
65
66 static std::variant<StreamErrorElement, QXmppError> fromDom(const QDomElement &);
67 void toXml(XmlWriter &) const;
68
69 Condition condition;
70 QString text;
71
72 bool operator==(const StreamErrorElement &o) const { return condition == o.condition && text == o.text; }
73};
74
75} // namespace QXmpp::Private
76
77#endif // STREAMERROR_H
StreamError
Definition QXmppStreamError.h:15