-
Notifications
You must be signed in to change notification settings - Fork 2
/
LibUsbguard.h
90 lines (74 loc) · 2.07 KB
/
LibUsbguard.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
//
// Copyright (C) 2023 Pino Toscano
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
// Authors: Pino Toscano <toscano.pino@tiscali.it>
//
#pragma once
#include <QMetaType>
#include <QString>
#include <stdint.h>
#include <Rule.hpp>
#include <USB.hpp>
class QDebug;
class Rule
{
public:
// MUST match usbguard::Rule::Target
enum class Target {
Allow = 0,
Block = 1,
Reject = 2,
Match = 3,
Unknown = 4,
Device = 5,
Empty = 6,
Invalid = 7,
};
static const uint32_t ImplicitID;
Rule();
~Rule();
const usbguard::Rule::Attribute<usbguard::USBInterfaceType>& attributeWithInterface() const;
const usbguard::USBDeviceID& getDeviceID() const;
QString getHash() const;
QString getName() const;
QString getParentHash() const;
uint32_t getRuleID() const;
QString getSerial() const;
Target getTarget() const;
QString getViaPort() const;
void setRuleID(uint32_t rule_id);
void setTarget(Target target);
static Rule fromString(const QString& str);
static QString targetToString(Target target);
private:
QString toString() const;
usbguard::Rule _rule;
friend QDebug& operator<<(QDebug& out, const Rule& rule);
};
class DeviceManager
{
public:
// MUST match usbguard::DeviceManager::EventType
enum class EventType {
Present = 0,
Insert = 1,
Update = 2,
Remove = 3,
};
};
QDebug& operator<<(QDebug& out, const Rule& rule);
QDebug& operator<<(QDebug& out, const Rule::Target& target);
Q_DECLARE_METATYPE(Rule::Target);