1 /*
2  * Copyright (C) 2008-2021 The QXmpp developers
3  *
4  * Authors:
5  *  Linus Jahn
6  *
7  * Source:
8  *  https://github.com/qxmpp-project/qxmpp
9  *
10  * This file is a part of QXmpp library.
11  *
12  * This library is free software; you can redistribute it and/or
13  * modify it under the terms of the GNU Lesser General Public
14  * License as published by the Free Software Foundation; either
15  * version 2.1 of the License, or (at your option) any later version.
16  *
17  * This library is distributed in the hope that it will be useful,
18  * but WITHOUT ANY WARRANTY; without even the implied warranty of
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
20  * Lesser General Public License for more details.
21  *
22  */
23 
24 #ifndef QXMPPSTARTTLSPACKET_H
25 #define QXMPPSTARTTLSPACKET_H
26 
27 #include "QXmppStanza.h"
28 
29 ///
30 /// \brief The QXmppStartTlsPacket represents packets used for initiating
31 /// STARTTLS negotiation when connecting.
32 ///
33 /// \ingroup Stanzas
34 ///
35 class QXMPP_EXPORT QXmppStartTlsPacket : public QXmppStanza
36 {
37 public:
38     /// The type of the STARTTLS packet.
39     enum Type {
40         StartTls,  ///< Used by the client to initiate STARTTLS.
41         Proceed,   ///< Used by the server to accept STARTTLS.
42         Failure    ///< Used by the server to reject STARTTLS.
43     };
44 
45     QXmppStartTlsPacket(Type type = StartTls);
46     ~QXmppStartTlsPacket() override;
47 
48     Type type() const;
49     void setType(Type type);
50 
51     /// \cond
52     void parse(const QDomElement &element) override;
53     void toXml(QXmlStreamWriter *writer) const override;
54     /// \endcond
55 
56     static bool isStartTlsPacket(const QDomElement &element);
57     static bool isStartTlsPacket(const QDomElement &element, Type type);
58 
59 private:
60     Type m_type;
61 };
62 
63 Q_DECLARE_METATYPE(QXmppStartTlsPacket::Type);
64 
65 #endif  // QXMPPSTARTTLSPACKET_H
66