1 | // Copyright (C) 2017 The Qt Company Ltd. |
---|---|
2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
3 | |
4 | #ifndef QHSTSPOLICY_H |
5 | #define QHSTSPOLICY_H |
6 | |
7 | #include <QtNetwork/qtnetworkglobal.h> |
8 | |
9 | #include <QtCore/qshareddata.h> |
10 | #include <QtCore/qflags.h> |
11 | #include <QtCore/qurl.h> |
12 | |
13 | QT_BEGIN_NAMESPACE |
14 | |
15 | class QHstsPolicyPrivate; |
16 | class QDateTime; |
17 | class QString; |
18 | class Q_NETWORK_EXPORT QHstsPolicy |
19 | { |
20 | public: |
21 | enum PolicyFlag |
22 | { |
23 | IncludeSubDomains = 1 |
24 | }; |
25 | Q_DECLARE_FLAGS(PolicyFlags, PolicyFlag) |
26 | |
27 | QHstsPolicy(); |
28 | QHstsPolicy(const QDateTime &expiry, PolicyFlags flags, const QString &host, |
29 | QUrl::ParsingMode mode = QUrl::DecodedMode); |
30 | QHstsPolicy(const QHstsPolicy &rhs); |
31 | QHstsPolicy &operator=(const QHstsPolicy &rhs); |
32 | QHstsPolicy &operator=(QHstsPolicy &&other) noexcept { swap(other); return *this; } |
33 | ~QHstsPolicy(); |
34 | |
35 | void swap(QHstsPolicy &other) noexcept { d.swap(other&: other.d); } |
36 | |
37 | void setHost(const QString &host, QUrl::ParsingMode mode = QUrl::DecodedMode); |
38 | QString host(QUrl::ComponentFormattingOptions options = QUrl::FullyDecoded) const; |
39 | void setExpiry(const QDateTime &expiry); |
40 | QDateTime expiry() const; |
41 | void setIncludesSubDomains(bool include); |
42 | bool includesSubDomains() const; |
43 | |
44 | bool isExpired() const; |
45 | |
46 | private: |
47 | QSharedDataPointer<QHstsPolicyPrivate> d; |
48 | |
49 | bool isEqual(const QHstsPolicy &other) const; |
50 | friend bool operator==(const QHstsPolicy &lhs, const QHstsPolicy &rhs) |
51 | { return lhs.isEqual(other: rhs); } |
52 | friend bool operator!=(const QHstsPolicy &lhs, const QHstsPolicy &rhs) |
53 | { return !lhs.isEqual(other: rhs); } |
54 | }; |
55 | |
56 | Q_DECLARE_SHARED(QHstsPolicy) |
57 | Q_DECLARE_OPERATORS_FOR_FLAGS(QHstsPolicy::PolicyFlags) |
58 | |
59 | |
60 | |
61 | QT_END_NAMESPACE |
62 | |
63 | #endif // QHSTSPOLICY_H |
64 |