File indexing completed on 2024-05-12 05:36:53

0001 /*
0002  * SPDX-FileCopyrightText: 2018-2019 Daniel Vrátil <dvratil@kde.org>
0003  *
0004  * SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0005  */
0006 
0007 #ifndef BOLT_ENUM_H_
0008 #define BOLT_ENUM_H_
0009 
0010 #include "kbolt_export.h"
0011 
0012 #include <QMetaObject>
0013 #include <QMetaType>
0014 #include <QString>
0015 
0016 namespace Bolt
0017 {
0018 // NOTE: Keep this split over two lines otherwise MOC may fail to see
0019 // the Q_NAMESPACE macro if KBOLT_EXPORT is not expanded correctly.
0020 KBOLT_EXPORT
0021 Q_NAMESPACE
0022 
0023 enum class Status {
0024     Unknown = -1,
0025     Disconnected,
0026     Connecting,
0027     Connected,
0028     Authorizing,
0029     AuthError,
0030     Authorized,
0031 };
0032 
0033 Q_ENUM_NS(Status)
0034 
0035 Status statusFromString(const QString &str);
0036 QString statusToString(Status status);
0037 
0038 enum class Auth {
0039     None = 0,
0040     NoPCIE = 1 << 0,
0041     Secure = 1 << 1,
0042     NoKey = 1 << 2,
0043     Boot = 1 << 3,
0044 };
0045 Q_ENUM_NS(Auth)
0046 Q_DECLARE_FLAGS(AuthFlags, Auth)
0047 
0048 AuthFlags authFlagsFromString(const QString &str);
0049 QString authFlagsToString(AuthFlags flags);
0050 
0051 enum class KeyState {
0052     Unknown = -1,
0053     Missing,
0054     Have,
0055     New,
0056 };
0057 Q_ENUM_NS(KeyState)
0058 
0059 KeyState keyStateFromString(const QString &str);
0060 
0061 enum class Policy {
0062     Unknown = -1,
0063     Default,
0064     Manual,
0065     Auto,
0066 };
0067 Q_ENUM_NS(Policy)
0068 
0069 Policy policyFromString(const QString &str);
0070 QString policyToString(Policy policy);
0071 
0072 enum class Type {
0073     Unknown = -1,
0074     Host,
0075     Peripheral,
0076 };
0077 Q_ENUM_NS(Type)
0078 
0079 Type typeFromString(const QString &str);
0080 
0081 enum class AuthMode {
0082     Disabled = 0,
0083     Enabled,
0084 };
0085 Q_ENUM_NS(AuthMode)
0086 
0087 AuthMode authModeFromString(const QString &str);
0088 QString authModeToString(AuthMode authMode);
0089 
0090 enum class Security {
0091     Unknown = -1,
0092     None,
0093     DPOnly,
0094     User = '1', /* sic! */
0095     Secure = '2', /* sic! */
0096     USBOnly = 4,
0097 };
0098 Q_ENUM_NS(Security)
0099 
0100 Security securityFromString(const QString &str);
0101 
0102 } // namespace
0103 
0104 Q_DECLARE_METATYPE(Bolt::Status)
0105 Q_DECLARE_METATYPE(Bolt::AuthFlags)
0106 Q_DECLARE_METATYPE(Bolt::KeyState)
0107 Q_DECLARE_METATYPE(Bolt::Policy)
0108 Q_DECLARE_METATYPE(Bolt::Type)
0109 Q_DECLARE_METATYPE(Bolt::AuthMode)
0110 Q_DECLARE_METATYPE(Bolt::Security)
0111 Q_DECLARE_OPERATORS_FOR_FLAGS(Bolt::AuthFlags)
0112 
0113 #endif