Changeset View
Changeset View
Standalone View
Standalone View
libs/bolt/enum.h
- This file was added.
1 | /* | ||||
---|---|---|---|---|---|
2 | * Copyright (c) 2018 - 2019 Daniel Vrátil <dvratil@kde.org> | ||||
3 | * | ||||
4 | * This program is free software; you can redistribute it and/or | ||||
5 | * modify it under the terms of the GNU General Public License as | ||||
6 | * published by the Free Software Foundation; either version 2 of | ||||
7 | * the License or (at your option) version 3 or any later version | ||||
8 | * accepted by the membership of KDE e.V. (or its successor approved | ||||
9 | * by the membership of KDE e.V.), which shall act as a proxy | ||||
10 | * defined in Section 14 of version 3 of the license. | ||||
11 | * | ||||
12 | * This program is distributed in the hope that it will be useful, | ||||
13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
15 | * GNU General Public License for more details. | ||||
16 | * | ||||
17 | * You should have received a copy of the GNU General Public License | ||||
18 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
19 | */ | ||||
20 | | ||||
21 | #ifndef BOLT_ENUM_H_ | ||||
22 | #define BOLT_ENUM_H_ | ||||
23 | | ||||
24 | #include "kbolt_export.h" | ||||
25 | | ||||
26 | #include <QMetaType> | ||||
27 | #include <QMetaObject> | ||||
28 | #include <QString> | ||||
29 | | ||||
30 | namespace Bolt | ||||
31 | { | ||||
32 | // NOTE: Keep this split over two lines otherwise MOC may fail to see | ||||
33 | // the Q_NAMESPACE macro if KBOLT_EXPORT is not expanded correctly. | ||||
34 | KBOLT_EXPORT | ||||
35 | Q_NAMESPACE | ||||
36 | | ||||
37 | enum class Status { | ||||
38 | Unknown = -1, | ||||
39 | Disconnected, | ||||
40 | Connecting, | ||||
41 | Connected, | ||||
42 | Authorizing, | ||||
43 | AuthError, | ||||
44 | Authorized | ||||
45 | }; | ||||
46 | | ||||
47 | Q_ENUM_NS(Status) | ||||
48 | | ||||
49 | Status statusFromString(const QString &str); | ||||
50 | QString statusToString(Status status); | ||||
51 | | ||||
52 | enum class Auth { | ||||
53 | None = 0, | ||||
54 | NoPCIE = 1 << 0, | ||||
55 | Secure = 1 << 1, | ||||
56 | NoKey = 1 << 2, | ||||
57 | Boot = 1 << 3 | ||||
58 | }; | ||||
59 | Q_ENUM_NS(Auth) | ||||
60 | Q_DECLARE_FLAGS(AuthFlags, Auth) | ||||
61 | | ||||
62 | AuthFlags authFlagsFromString(const QString &str); | ||||
63 | QString authFlagsToString(AuthFlags flags); | ||||
64 | | ||||
65 | enum class KeyState { | ||||
66 | Unknown = -1, | ||||
67 | Missing, | ||||
68 | Have, | ||||
69 | New | ||||
70 | }; | ||||
71 | Q_ENUM_NS(KeyState) | ||||
72 | | ||||
73 | KeyState keyStateFromString(const QString &str); | ||||
74 | | ||||
75 | enum class Policy { | ||||
76 | Unknown = -1, | ||||
77 | Default, | ||||
78 | Manual, | ||||
79 | Auto | ||||
80 | }; | ||||
81 | Q_ENUM_NS(Policy) | ||||
82 | | ||||
83 | Policy policyFromString(const QString &str); | ||||
84 | QString policyToString(Policy policy); | ||||
85 | | ||||
86 | enum class Type { | ||||
87 | Unknown = -1, | ||||
88 | Host, | ||||
89 | Peripheral | ||||
90 | }; | ||||
91 | Q_ENUM_NS(Type) | ||||
92 | | ||||
93 | Type typeFromString(const QString &str); | ||||
94 | | ||||
95 | | ||||
96 | enum class AuthMode { | ||||
97 | Disabled = 0, | ||||
98 | Enabled | ||||
99 | }; | ||||
100 | Q_ENUM_NS(AuthMode) | ||||
101 | | ||||
102 | AuthMode authModeFromString(const QString &str); | ||||
103 | QString authModeToString(AuthMode authMode); | ||||
104 | | ||||
105 | enum class Security { | ||||
106 | Unknown = -1, | ||||
107 | None, | ||||
108 | DPOnly, | ||||
109 | User = '1', | ||||
110 | Secure = '2', | ||||
111 | USBOnly = 4 | ||||
112 | }; | ||||
113 | Q_ENUM_NS(Security) | ||||
114 | | ||||
115 | Security securityFromString(const QString &str); | ||||
116 | | ||||
117 | } // namespace | ||||
118 | | ||||
119 | Q_DECLARE_METATYPE(Bolt::Status) | ||||
120 | Q_DECLARE_METATYPE(Bolt::AuthFlags) | ||||
121 | Q_DECLARE_METATYPE(Bolt::KeyState) | ||||
122 | Q_DECLARE_METATYPE(Bolt::Policy) | ||||
123 | Q_DECLARE_METATYPE(Bolt::Type) | ||||
124 | Q_DECLARE_METATYPE(Bolt::AuthMode) | ||||
125 | Q_DECLARE_METATYPE(Bolt::Security) | ||||
126 | Q_DECLARE_OPERATORS_FOR_FLAGS(Bolt::AuthFlags) | ||||
127 | | ||||
128 | | ||||
129 | #endif |